jawadi121 / smart-lencioni-image-resizer

Automatically exported from code.google.com/p/smart-lencioni-image-resizer
GNU General Public License v3.0
0 stars 0 forks source link

Problem with conversion of one specific transparent PNG on r48 #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. convert the attached swan image with all defaults
2.
3.

What is the expected output? What do you see instead?
copy of original image. weird banding and reversed colors

What version of the product are you using? On what operating system?
r48 on Linux - php 5.2.11

Please provide any additional information below.

Original issue reported on code.google.com by adrianbj...@gmail.com on 15 Dec 2009 at 10:59

Attachments:

GoogleCodeExporter commented 9 years ago
Just to follow up on this - after posting that initial message I saw that the
original image had a black background. However, when I open it in Photoshop, the
background is definitely transparent. Anyway, I resaved it and now SLIR works 
fine on
the new version. The weird thing is that the original one was created by 
imagemagick
from an SVG file. However, many other transparent PNGs were created in the same 
way
and didn't have the black background problem, so still not really sure what is 
going on.

Original comment by adrianbj...@gmail.com on 15 Dec 2009 at 11:15

GoogleCodeExporter commented 9 years ago
I should follow up further with this. It turns out that when imagemagick 
converts
this SVG to PNG, it is making it PseudoClass, rather than DirectClass, which
effectively means that the PNG is GrayScale, rather than RGB. This is why SLIR 
has
problems with it. I have posted on the imagemagick forums to hopefully figure 
out how
I can force it to remain RGB, even though the original vector only has grayscale
elements.

Original comment by adrianbj...@gmail.com on 25 Jan 2010 at 7:39

GoogleCodeExporter commented 9 years ago
Interesting. It looks like this is a problem with GD: http://bugs.libgd.org/?
do=details&task_id=88

According to Pierre Joye on May 1, 2009, the "next version of GD will support 
grayscale 
images as internal formats, that will greatly ease this kind of 
transformation." 
http://bugs.php.net/bug.php?id=48123#c147648

The temporary solution seems to be to either use full grayscale images (without 
alpha 
transparency) or RGB images.

Original comment by joe.lencioni on 27 Jan 2010 at 3:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi Joe,

Thanks for looking into that. I have actually been investigating the root cause
myself and thought it might be helpful for others.

I have been using imagemagick to convert my SVG into the initial PNG that SLIR 
receives.

It turns out that if I ensure that the colormode of the original SVG is RGB and 
not
CMYK (when saving it from Illustrator), then imagemagick creates a transparent 
PNG
which is TrueColorMatte. What is confusing is that whether the original SVG is 
RGB or
CMYK, the original SVG and the converted PNG are still listed as having an RGB
Colorspace (via IM's identify). The only difference I can see when creating the 
SVG
(via Illustrator's Save for Web) is that CMYK color mode results in "Bilevel",
whereas RGB color mode results in "TrueColorMatte".

Would be great if Imagemagick could convert the Bilevel SVG to a TrueColorMatte 
PNG,
but at least I have a workaround for now - I just need to make sure that users
uploading ensure they are in RGB mode - not an ideal situation.

Original comment by adrianbj...@gmail.com on 27 Jan 2010 at 10:29

GoogleCodeExporter commented 9 years ago
Just wanted to follow up with my Imagemagick solution. I am actually using the
imagick php wrapper, but the following commands do the trick and maintain
TrueColorMatte even if the image only contains grayscale elements.

$imagickImage->setImageFormat("png32");
$imagickImage->setImageDepth(8);
$imagickImage->setImageColorSpace(imagick::COLORSPACE_RGB);     
$imagickImage->setImageType(imagick::IMGTYPE_TRUECOLORMATTE);
$imagickImage->setOption("png:color-type","6");

It should also be noted that IM's identify has what might be considered strange
behavior when it comes to reporting - read this post for more details:
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=15444

Original comment by adrianbj...@gmail.com on 16 Feb 2010 at 1:50