Format BGRA doesn't work

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Format BGRA doesn't work

Post by Drarakel »

Either this is a bug - or the formats list is wrong..

With IM v6.6.3-7 Q16, on Windows XP, these formats are in my "convert -list format" list:

Code: Select all

      BGR* RGB       rw+   Raw blue, green, and red samples
     BGRA* RGB       rw+   Raw blue, green, red and alpha samples
BGR works, but not BGRA. Some test commands:

Code: Select all

convert logo: -transparent white bgra:test.bin
convert logo: -transparent white rgba:- | identify -depth 8 -size 640x480 bgra:-
I get a 0 byte file or an "invalid argument" error (when writing) and a "no decode delegate" error (when reading).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Format BGRA doesn't work

Post by fmw42 »

I get "no decode delegate" error on my Mac OSX Tiger, IM 6.6.3.7 Q16 (HDRI) for the second line and a file called bgra/test.bin for the first line.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

So.. there's no such delegate (and the behaviour when writing with 'bgra:' depends a bit on the OS and how exactly the filename is written).
Thanks for the confirmation.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

Edit coder.xml and associate BGRA with RGB. In the mean-time we'll add a patch to ImageMagick 6.6.3-8 Beta to fix the problem.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

Editing coder.xml alone doesn't work yet. So, I'll wait for the next release version.
Thanks!
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

There are still problems in IM v6.6.3-8 (Q16, Windows XP) with this format.

Writing with 'BGRA' creates the same files as with 'BGR' (so, the alpha channel is omitted):

Code: Select all

convert logo: -transparent white BGR:test.bgr
convert logo: -transparent white BGRA:test.bgra
And reading with 'BGRA' doesn't work either here.
First an example that works (transparent logo image written as RGBA, again read as RGBA):

Code: Select all

convert logo: -transparent white RGBA:- | identify -verbose -depth 8 -size 640x480 RGBA:-
You will get the normal image and the 'normal' statistics.
When I read that as 'BGRA', the red and blue channels should be swapped - everything else should be the same. But it isn't:

Code: Select all

convert logo: -transparent white RGBA:- | identify -verbose -depth 8 -size 640x480 BGRA:-
...
Format: BGRA (Raw blue, green, red and alpha samples)
...
Histogram:
306240: ( 0, 0, 0,255) #000000 black
480: ( 1, 1,131,254) #010183FE rgba(1,1,131,0.996078)
480: ( 4, 2, 16,254) #040210FE rgba(4,2,16,0.996078)
...
The resulting image is almost completely black (with sometimes a few colored stripes).

The behaviour was the same in version 6.6.3-7 (with modified coder.xml).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

We can reproduce the problem you posted and will have a patch in ImageMagick 6.6.3-9 Beta within a day or two. Thanks,
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

Thanks.
But in IM v6.6.3-9, it doesn't work yet.

The BGRA reading part is the same (with the almost completely black image as result).
Writing as BGRA now produces the correct filesize, but the image is corrupt / fully black (tested here with 'RGBA' as input format):

Code: Select all

convert logo: -transparent white BGRA:- | identify -depth 8 -size 640x480 -verbose RGBA:-
And the format 'BGR' is now broken, too. Writing as BGR results in a fully black, one sample per pixel file (300KiB instead of 900KiB in the logo image example). And reading with BGR gives also almost completely black images.


Besides: In v6.6.3-9 (at least with my Windows Q16 binary), "RGBO", "RBG", "BRG", "GBR" and "GRB" disappeared from the formats list. Was this intended?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

Our patch was not properly exported out development environment to the ImageMagick trunk. Look for the patch in ImageMagick 6.6.3-10 Beta by sometime tomorrow. Thanks.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

Thanks. In IM version 6.6.3-10, the format BGRA works.

The downside: Format BGR is broken (since version 6.6.3-9).

Writing the IM logo as BGR still results in a wrong 300 KiB file (should be 900 KiB).

Code: Select all

convert logo: BGR:logo.bgr
convert -depth 8 -size 640x480 gray:logo.bgr logo.bgr_gray.png
Image

Something similar happened with the reading part of 'BGR':

Code: Select all

convert logo: rgb:logo.rgb
convert -depth 8 -size 640x480 bgr:logo.rgb logo.rgb_bgr.png
Image Image Image
(Of course, the color channels are swapped by reading an RGB image as BGR. But that's not the problem here.)

And the formats "RGBO", "RBG", "BRG", "GBR" and "GRB" don't work at all:
Drarakel wrote:In v6.6.3-9 (at least with my Windows Q16 binary), "RGBO", "RBG", "BRG", "GBR" and "GRB" disappeared from the formats list. Was this intended?
All of these formats worked up till version 6.6.3-8.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.4-0 Beta available by sometime tomorrow. Thanks.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

With IM v6.6.4-0, "BGR" and "BGRA" works. Thank you!

But I have to ask again: :)
Drarakel wrote:In v6.6.3-9 (at least with my Windows Q16 binary), "RGBO", "RBG", "BRG", "GBR" and "GRB" disappeared from the formats list. Was this intended?
So.. It seems that the result of this thread was that a) you had a lot of work, b) one format that didn't work before (BGRA) now does work, but c) 5 formats that did work before now don't work anymore. :-/
Or is this still a bug?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

RGBO should work. The other formats were supported with contributed code and clearly did not work properly / robustly. We're working on a robust implementation to support the RGBA/CMYKA combinatorics.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Format BGRA doesn't work

Post by Drarakel »

OK, thanks for the explanation!
magick wrote:RGBO should work.
With my ImageMagick version 6.6.4-0 Q16, on Windows XP, it does not work (even after adding "RGBO" to coder.xml). It's also not on the "convert -list format" list (since version 6.6.3-9).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Format BGRA doesn't work

Post by magick »

The RGBO coder is there but for some reason its not showing up in the format list. We have a fix for the problem in a day or two. Thanks.
Post Reply