Hello there,
I have quite strange problem, as I see it.
My input file is a PDF and I'm creating two different jpg files from the PDF, one thumbnail and one preview.
On some PDF files white areas are turning black, especially white backgrounds. The strange thing is that it only happens when I add a -scale command in command line.
If I exclude the -scale command, the file looks perfect.
Using ImageMagick 6.7.4-2 Q16 dll
GhostScript 9.04
Windows 2008 R2 Server 64-bit
For thumbnails I use this command:
-convert -colorspace sRGB -scale 100x100 my_input_file.pdf my_output_file.jpg
For previews I use this command
-convert -colorspace sRGB my_input_file.pdf my_output_file.jpg
The only thing that differs is the -scale command, I've tried using different ways to specify the size, with no luck.
Any ideas of what I'm doing wrong?
Best regards,
Patrik Berzander
White areas in PDF turns black in JPG output
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: White areas in PDF turns black in JPG output
put the -scale after your input image in the command line
Re: White areas in PDF turns black in JPG output
Thanks for your answer, unfortunately that doesn't make a difference at all.
Same output even if I use:
-convert -colorspace sRGB my_input_file.pdf -scale 100x100 my_input_file.pdf my_output_file.jpg
I've also tried
convert my_input_file.pdf -colorspace sRGB -scale 100x100 my_output_file.jpg
and
convert my_input_file.pdf -scale 100x100 my_output_file.jpg
All these gives me the same incorrect output.
I appreciate any help I can get!
Same output even if I use:
-convert -colorspace sRGB my_input_file.pdf -scale 100x100 my_input_file.pdf my_output_file.jpg
I've also tried
convert my_input_file.pdf -colorspace sRGB -scale 100x100 my_output_file.jpg
and
convert my_input_file.pdf -scale 100x100 my_output_file.jpg
All these gives me the same incorrect output.
I appreciate any help I can get!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: White areas in PDF turns black in JPG output
Can you post a link to one of the troubling pdf files so others can test with it?
Re: White areas in PDF turns black in JPG output
Try with the "-background white" option.
Re: White areas in PDF turns black in JPG output
I just tried -background white as well, however with the same incorrect result.
If anyone would like to give it a try, here are links to all files.
Original PDF file:
http://212.181.38.117:8080/im/String.pdf
The following command "convert -colorspace sRGB String.pdf Preview.jpg" created this file:
http://212.181.38.117:8080/im/Preview.jpg
The following command "convert -colorspace sRGB String.pdf -scale 100x100 Thumbnail.jpg" created this file:
http://212.181.38.117:8080/im/Thumbnail.jpg
Thanks again for looking into this, much appreciated!
If anyone would like to give it a try, here are links to all files.
Original PDF file:
http://212.181.38.117:8080/im/String.pdf
The following command "convert -colorspace sRGB String.pdf Preview.jpg" created this file:
http://212.181.38.117:8080/im/Preview.jpg
The following command "convert -colorspace sRGB String.pdf -scale 100x100 Thumbnail.jpg" created this file:
http://212.181.38.117:8080/im/Thumbnail.jpg
Thanks again for looking into this, much appreciated!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: White areas in PDF turns black in JPG output
your image has transparency and jpg does not support transparency, so you have to flatten it against a white background (or save to gif or png or tiff)
try this, it works for me
convert -colorspace sRGB string.pdf -scale 100x100 -background white -flatten string.jpg
try this, it works for me
convert -colorspace sRGB string.pdf -scale 100x100 -background white -flatten string.jpg
Re: White areas in PDF turns black in JPG output
Thank you so much, now it works like a charm!
Seems to work fine without the -background white command as well.
Thanks again!
Seems to work fine without the -background white command as well.
Thanks again!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: White areas in PDF turns black in JPG output
The default -background is white.patrikcar wrote:Thank you so much, now it works like a charm!
Seems to work fine without the -background white command as well.
Thanks again!
see
http://www.imagemagick.org/Usage/layers/#flatten
http://www.imagemagick.org/script/comma ... background
Re: White areas in PDF turns black in JPG output
Wonderful! thanks a lot!fmw42 wrote: ↑2012-01-11T15:38:53-07:00 your image has transparency and jpg does not support transparency, so you have to flatten it against a white background (or save to gif or png or tiff)
try this, it works for me
convert -colorspace sRGB string.pdf -scale 100x100 -background white -flatten string.jpg