(see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=642098)
convert -density 300 test.pdf -colorspace RGB -resize 900 test.jpg lead to incorrect background color.
It is a regression.
Not tested with lasted upstream imagemagick but do not see solved in changelog
Bastien
Background color error on PDF resize
Re: Background color error on PDF resize
Not a bug. Recent versions of ImageMagick use the Ghostscript pngalpha device to render PDF. The pngalpha device includes an alpha channel. To get the desired results, flatten the image:
- convert -density 300 -colorspace RGB test.pdf -flatten -resize 900 test.jpg
-
- Posts: 467
- Joined: 2008-12-21T11:51:10-07:00
Re: Background color error on PDF resize
Sorry but jpeg has no alpha channel. Why not flatten by default ?
At least warning.
Bastien
At least warning.
Bastien
Re: Background color error on PDF resize
Here, the flatten is required before the image is delivered to the JPEG coder. The resize algorithm considers alpha when resizing the RGB channels. Note, the user can change pngalpha to pnmraw in the delegates.xml configuration file and PDF's will always render without an alpha channel.
-
- Posts: 467
- Joined: 2008-12-21T11:51:10-07:00
Re: Background color error on PDF resize
I understand but without flatten
pdf to png will be correct thanks to alpha channel whereas convertion from pdf to jpg with resize will be not correct.
pdf to png will be correct thanks to alpha channel whereas convertion from pdf to jpg with resize will be not correct.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Background color error on PDF resize
With more recent versions of IM (v6.7.5 onward), especially if multiple images are involved, use -alpha removemagick wrote:Not a bug. Recent versions of ImageMagick use the Ghostscript pngalpha device to render PDF. The pngalpha device includes an alpha channel. To get the desired results, flatten the image:
- convert -density 300 -colorspace RGB test.pdf -flatten -resize 900 test.jpg
Code: Select all
convert -density 300 -colorspace RGB test.pdf -background white -alpha remove -resize 900 test.jpg
See IM Examples, "Removing transparency form images"
http://www.imagemagick.org/Usage/masking/#remove
This also shows why you should remove alpha, BEFORE saving to JPEG...
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Background color error on PDF resize
It is actually 'correct'. But transparenct colours are undefined. You just need to define what they should be.broucaries wrote:I understand but without flatten
pdf to png will be correct thanks to alpha channel whereas conversion from pdf to jpg with resize will be not correct.
However I agree that perhaps JPEG saving should apply a '-alpha remove' automatically as part of its coding sequence (especially now a memory efficient operator is available). I would think this should be a IMv7 coder change (in development), and NOT a IMv6 change. JPG transparency problem has been a well known IMv6 thing for far too long.
Note that this assumes that 'background' is actually set correctly (default is white). Who is to say that it is correct in all situations?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Background color error on PDF resize
I do not think it should be automatic, since there is no universal background color. The background color is specific to the user's application and/or desires.