Search code examples
phpimagemagickimage-conversion

How can i get the name of resulting converted images from a pdf using php imagemagick?


Im converting some pdfs to pngs wth

exec("convert readme.pdf readme.png")

And then i need to store in a mysql database the resulting image filenames from any given pdf.

This is because when i convert in this manner and the source pdfs are more than one page i get a series of: readme-0.png readme-1.png readme-2.png

So the question is: how can i determine after conversion the resulting image filenames?

Thanks in advance, hope i made myself clear.


Solution

  • It'll always be originalname-#.png for multi-page conversions.

    $input = "readme.pdf";
    $basename = basename($input, '.pdf');
    
    $images = glob("{$basename}-*.png");