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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
danisack
Posts: 3
Joined: 2015-10-14T06:57:19-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Post your PDF document so the IM developers or some one else can test with it.
danisack
Posts: 3
Joined: 2015-10-14T06:57:19-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
danisack
Posts: 3
Joined: 2015-10-14T06:57:19-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

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

Post by dlemstra »

Would you be willing to help us with that Fred?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Post Reply