Transparent pixels changing color when scaling
Posted: 2012-11-29T09:00:34-07:00
I'm running into some issues using convert---it appears that transparent white pixels are being changed to transparent black pixels when resizing an image.
Reproduction steps:
Use the following test file (testcase.txt)
# ImageMagick pixel enumeration: 2,2,255,srgba
0,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
Now run the command
convert -scale 200% testcase.txt out.txt
The result in out.txt is:
# ImageMagick pixel enumeration: 4,4,255,srgba
0,0: ( 0, 0, 0, 0) #00000000 none
1,0: ( 0, 0, 0, 0) #00000000 none
2,0: ( 0, 0, 0, 0) #00000000 none
3,0: ( 0, 0, 0, 0) #00000000 none
0,1: ( 0, 0, 0, 0) #00000000 none
1,1: ( 0, 0, 0, 0) #00000000 none
2,1: ( 0, 0, 0, 0) #00000000 none
3,1: ( 0, 0, 0, 0) #00000000 none
0,2: ( 0, 0, 0, 0) #00000000 none
1,2: ( 0, 0, 0, 0) #00000000 none
2,2: ( 0, 0, 0, 0) #00000000 none
3,2: ( 0, 0, 0, 0) #00000000 none
0,3: ( 0, 0, 0, 0) #00000000 none
1,3: ( 0, 0, 0, 0) #00000000 none
2,3: ( 0, 0, 0, 0) #00000000 none
3,3: ( 0, 0, 0, 0) #00000000 none
The white transparent pixels have become black transparent pixels. This does not occur when using -scale 100% --- the output is identical to the input in that case.
This worked as expected in version 6.5.7-0, producing the output
# ImageMagick pixel enumeration: 4,4,255,srgba
0,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
I suspect this is a bug, since I don't think that simply scaling an image should change the colors of the pixels in this manner. (I originally observed this issue when converting gif to png, but was able to reproduce it in the above test case using text files.) I apologize if I am simply misunderstanding how the convert command should be used. Any help would be greatly appreciated.
Thanks,
Eric
OS:
CentOS release 5.7 (Final)
ImageMagic:
Version: ImageMagick 6.8.0-7 2012-11-28 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Reproduction steps:
Use the following test file (testcase.txt)
# ImageMagick pixel enumeration: 2,2,255,srgba
0,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
Now run the command
convert -scale 200% testcase.txt out.txt
The result in out.txt is:
# ImageMagick pixel enumeration: 4,4,255,srgba
0,0: ( 0, 0, 0, 0) #00000000 none
1,0: ( 0, 0, 0, 0) #00000000 none
2,0: ( 0, 0, 0, 0) #00000000 none
3,0: ( 0, 0, 0, 0) #00000000 none
0,1: ( 0, 0, 0, 0) #00000000 none
1,1: ( 0, 0, 0, 0) #00000000 none
2,1: ( 0, 0, 0, 0) #00000000 none
3,1: ( 0, 0, 0, 0) #00000000 none
0,2: ( 0, 0, 0, 0) #00000000 none
1,2: ( 0, 0, 0, 0) #00000000 none
2,2: ( 0, 0, 0, 0) #00000000 none
3,2: ( 0, 0, 0, 0) #00000000 none
0,3: ( 0, 0, 0, 0) #00000000 none
1,3: ( 0, 0, 0, 0) #00000000 none
2,3: ( 0, 0, 0, 0) #00000000 none
3,3: ( 0, 0, 0, 0) #00000000 none
The white transparent pixels have become black transparent pixels. This does not occur when using -scale 100% --- the output is identical to the input in that case.
This worked as expected in version 6.5.7-0, producing the output
# ImageMagick pixel enumeration: 4,4,255,srgba
0,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,0: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,1: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,2: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
0,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
1,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
2,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
3,3: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)
I suspect this is a bug, since I don't think that simply scaling an image should change the colors of the pixels in this manner. (I originally observed this issue when converting gif to png, but was able to reproduce it in the above test case using text files.) I apologize if I am simply misunderstanding how the convert command should be used. Any help would be greatly appreciated.
Thanks,
Eric
OS:
CentOS release 5.7 (Final)
ImageMagic:
Version: ImageMagick 6.8.0-7 2012-11-28 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP