Page 1 of 1

Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-14T07:29:56-07:00
by danisack
IM version: Windows ImageMagick-6.9.2-4-Q16-x64-dll.exe
GhostScript version: 9.14

I want to convert a PDF document into a JPG picture.
Command: convert -define jpeg:extent=1024KB complete.pdf complete.jpg

The converted JPG has a very low quality and the restricted size of 1024KB is not reached.
I think this is a bug. I was trying some previous versions of IM (6.8.9_10 and lower) and everything works fine.
Can somebody confirm this behavior? Or what i am doing wrong?

Converting a JPG into a JPG with "-define jpeg:extent=1024KB", everything works fine.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-14T09:53:21-07:00
by fmw42
Post your PDF document so the IM developers or some one else can test with it.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-15T00:22:12-07:00
by danisack
fmw42 wrote:Post your PDF document so the IM developers or some one else can test with it.
Thanks for your fast reply.

For example you can take this PDF:
http://www.mueller.de/uploads/tx_muelle ... mplete.pdf
Or this:
http://www.mueller.de/uploads/tx_muelle ... mplete.pdf

I must convert many PDFs into JPGs and the "bug" occurs on every PDF.
If you find an PDF where the "bug" doesn't occurs, please post this PDF.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-15T09:03:35-07:00
by fmw42
I cannot seem to download those files.

Also you might be better off getting a pdf tool to extract the jpg image and then using either that tool, another, or IM to write to a specific size.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T03:34:35-07:00
by danisack
fmw42 wrote:I cannot seem to download those files.
...
Sorry for the "bad" links. For me, the links are correct. Maybe the links are exclusive for germany.

I find some ".com" URLs with PDFs:
http://www.superbrands.com/lkc1/pdf/12_consumerSB.pdf

http://sunnydayguide.com/sarasota/dynam ... vities.pdf

I want to convert the complete pages of a PDF document (all inclusive: pictures, fonts, ...). I tried different other tools, but IM was mostly the best (very fast, good quality, needs less resources).
My final IM convert statement is:
convert -depth 8 -density 200 -alpha remove -colorspace sRGB -define jpeg:extent=1024KB test.pdf test.jpg

But with the latest version of IM the option "-define jpeg:extent=1024KB" doesn't work on my system.
Maybe somebody can confirm this behavior.

Thanks for your help.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T09:27:14-07:00
by fmw42
I can confirm that one gets a much closer value with older versions of IM

With IM 6.9.2.4 Q16 Mac OSX and no hint:

Code: Select all

convert -density 200 -alpha remove -colorspace sRGB 12_consumerSB.pdf \
-depth 8 12_consumerSB1.jpg
3.07MB

With IM 6.9.2.4 Q16 Mac OSX and with hint:

Code: Select all

convert -density 200 -alpha remove -colorspace sRGB 12_consumerSB.pdf \
-define jpeg:extent=1024KB -depth 8 12_consumerSB2.jpg
218KB

With IM 6.8.6.10 Q16 Mac OSX and with hint:

Code: Select all

im68610 convert -density 200 -alpha remove -colorspace sRGB 12_consumerSB.pdf \
-define jpeg:extent=1024KB -depth 8 12_consumerSB2.jpg
994KB

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T12:25:34-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.2-5 Beta, available by sometime tomorrow. Thanks.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T12:35:34-07:00
by dlemstra
This bug was introduced due to this feature: viewtopic.php?f=2&t=27071&p=120318. A temporary workaround is specifying the 'max quality' with -quality=100.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T13:49:40-07:00
by fmw42
dlemstra wrote:This bug was introduced due to this feature: viewtopic.php?f=2&t=27071&p=120318. A temporary workaround is specifying the 'max quality' with -quality=100.
Documentation at http://www.imagemagick.org/script/comma ... php#define needs to be updated to explain the connection between -quality and this define.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T14:11:14-07:00
by dlemstra
Would you be willing to help us with that Fred?

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-16T14:29:35-07:00
by fmw42
dlemstra wrote:Would you be willing to help us with that Fred?
If you can explain how -quality affects this define, I can change the docs. I really do not understand what was changed in the other topic and how it limits the -define.

Re: Convert PDF to JPG: jpeg:extent=1024KB doesn't work

Posted: 2015-10-22T14:53:40-07:00
by fmw42
The JPEG encoder will search for the highest compression quality level that results in an output file that does notexceed the value. The -quality option also will be respected starting with version 6.9.2-5. Between 6.9.1-0 and 6.9.2-4, add -quality 100 in order for the jpeg:extent to work properly, due to a bug. Prior to 6.9.1-0, the -quality setting was ignored.