cyberfly
cyberfly

Reputation: 5878

Extension problem when convert pdf to png using Imagemagick

I try to convert pdf file (5 pages) with imagemagick. I can convert it but i get a weird extension.

Example: fax.png.0, fax.png.1, fax.png.2, fax.png.3, fax.png.4

This is the command that i use:

convert -density 140 /var/www/html/ok/fax.pdf  -resize 25% -quality 100 -colors 256 /var/www/html/ok/fax.png

How to fix it so it will become only fax0.png, fax1.png, fax2.png, fax3.png, fax4.png

Thank you in advance

Upvotes: 1

Views: 320

Answers (4)

Sauer
Sauer

Reputation: 1479

I dont know, if this still helps you. But I had similar weird problems. I solved it, by simply deaktivating the alpha channel like this:

convert -alpha off -density 300 -quality 85 -... old.pdf new.tif

Upvotes: 1

cyberfly
cyberfly

Reputation: 5878

the solution for this problem is add the %d after the filename:

convert -density 140 /var/www/html/ok/fax.pdf  -resize 25% -quality 100 -colors 256 /var/www/html/ok/fax%d.png

read more here:

Filename Percent Escapes

Upvotes: 1

Dan Grossman
Dan Grossman

Reputation: 52372

I assume since you tagged this with php that you're using PHP, and not just imagemagick at the command line.

If so, use rename to change the file names as desired:

http://php.net/manual/en/function.rename.php

Upvotes: 1

Related Questions