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

66 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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

$input = "readme.pdf";
$basename = basename($input, '.pdf');

$images = glob("{$basename}-*.png");