To test this further, I created a very small, 2x2 pixel image with the following command:
PNG:
Code: Select all
convert \
-size 1x1 \
\( xc:red xc:green +append \) \
\( xc:blue xc:black +append \) \
-append \
2x2-pixels-red-green-blue-black.png
JPEG:
Code: Select all
convert 2x2-pixels-red-green-blue-black.png 2x2-pixels-red-green-blue-black---converted-from-png.jpeg
Code: Select all
convert 2x2-pixels-red-green-blue-black---converted-from-png.jpeg -scale 10000% show:
convert 2x2-pixels-red-green-blue-black.png -scale 10000% show:
PNG:
Code: Select all
convert 2x2-pixels-red-green-blue-black.png txt:-
# ImageMagick pixel enumeration: 2,2,255,srgb
0,0: (255,0,0) #FF0000 red
1,0: (0,128,0) #008000 green
0,1: (0,0,255) #0000FF blue
1,1: (0,0,0) #000000 black
Code: Select all
convert 2x2-pixels-red-green-blue-black---converted-from-png.jpeg txt:-
# ImageMagick pixel enumeration: 2,2,255,srgb
0,0: (239,0,155) #EF009B srgb(239,0,155)
1,0: (87,63,53) #573F35 srgb(87,63,53)
0,1: (69,0,141) #45008D srgb(69,0,141)
1,1: (0,0,29) #00001D srgb(0,0,29)
JPEG:
Code: Select all
convert \
-size 1x1 \
\( xc:red xc:green +append \) \
\( xc:blue xc:black +append \) \
-append \
2x2-pixels-red-green-blue-black---directly-generated.jpeg
- Question 1: Is this a bug or a feature? ("Feature" as in this being a side-effect of the JPEG compression, which doesn't work for small dimensions anyway...)
- Question 2: If this wrong colors cannot be avoided when using the methods shown above -- how else can I create a 2x2 pixels JPEG that returns the exact same color values as the PNG does ?!?