Page 1 of 1
Using -size and -quality in the same command
Posted: 2009-11-24T12:39:17-07:00
by virtual
I'm converting a PDF into PNG's using the following command:
Code: Select all
exec("convert -resize 500x700! -quality 50 input.pdf output.png");
However, the quality always seems to be set to 100 (the file size is 280kb!). Is there a way I can get the output.png to be < 100kb whilst also resizing?
Thanks!
Re: Using -size and -quality in the same command
Posted: 2009-11-24T12:47:31-07:00
by Bonzo
Version 6 should read the image in first, -strip removes all EXIF data etc. -thumbnail removes all EXIF data except the colour profile on earlier versions.
Try:
Code: Select all
exec("convert input.pdf -resize 500x700! -strip -quality 50 output.png");
You are saving as a png which has more colours; a smaller filesize would be jpg. Try them both and see the file size difference.
Re: Using -size and -quality in the same command
Posted: 2009-11-24T14:25:46-07:00
by fmw42
you should set the density before reading in the pdf. also see
http://www.imagemagick.org/script/comma ... hp#quality for what quality does with PNG. Also see
http://www.imagemagick.org/Usage/formats/#png_quality
If you want high quality png, then use supersampling by setting the density high and resizing to compensate, e.g.
convert -density 288 image.pdf -resize 25% result.png
density 288 = 4*72 dpi, so use 25% for resizing to get back to the same size. Reduce further if you desire.
Re: Using -size and -quality in the same command
Posted: 2009-11-24T16:05:23-07:00
by virtual
Fantastico! Thanks guys, I'll give that a go tomorrow. Great help!
Re: Using -size and -quality in the same command
Posted: 2009-11-24T17:13:33-07:00
by anthony
virtual wrote:I'm converting a PDF into PNG's using the following command:
Code: Select all
exec("convert -resize 500x700! -quality 50 input.pdf output.png");
However, the quality always seems to be set to 100 (the file size is 280kb!). Is there a way I can get the output.png to be < 100kb whilst also resizing?
Thanks!
-quality 50 is meaningful only to JPEG images. for PNG -quality uses very different values.
The first digit is compression with '9' as the highest, the second digit is encoding method and the best method depends on the type of image (real life, cartoon-like, etc)
To find the best compression for PNG look at "OptiPNG", For 8-bit (color table or palette) PNG whcih is smaller but lossy (whcih as you are resizing is obviously not an issue), you can also look at "pngng". See IM examples, Common File Formats, PNG non-IM PNG tools...
http://www.imagemagick.org/Usage/formats/#png_non-im