It is currently Mon Aug 03, 2026 10:20 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 12:58 pm  (#1) 
Offline
GimpChat Member

Joined: Feb 17, 2016
Posts: 8
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level



I have a gimp xcf file with just black pixels and fully transparent pixels.

I am exporting it to png format.

When I use that exported png in another command line program called ImageMagick it says "loading BILEV image".

So I assume that because there is only one color, the png exported is exporting to a more compact format. BUT, the format I need for this png to work properly with the processes it will go through after gimp, is an RGBA format.

Now it seems completely reasonable to ask it to create an RGBA format image with only two colors. Albeit, it is not optimal from a file size perspective, but still fully valid.

Is there a way I can force gimp to export to RGBA?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 1:43 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12822
Not sure how your PNG was saved. If it was saved as RGBA format, then I have no idea how ImageMagick would see it otherwise. When you open you PNG file in GIMP, if you go to Image>Mode>..., what do you see is the format for the PNG file? :)

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 2:00 pm  (#3) 
Offline
GimpChat Member

Joined: Feb 17, 2016
Posts: 8
lylejk wrote:
Not sure how your PNG was saved. If it was saved as RGBA format, then I have no idea how ImageMagick would see it otherwise. When you open you PNG file in GIMP, if you go to Image>Mode>..., what do you see is the format for the PNG file? :)


Color mode for both the xcf and the exported png is rgb, but imagemagick reads it as bilevel. But there is more relevent info I forgot to add.

If I have just black pixels, imagemagick reads the exported png as bilevel.

If I change one pixel to grey, imagemagick reads the exported png as format BW+A (black white plus alpha)

finally, if I add one red pixel, imagemagick will read the exported png as RGBA.

So it seems like the gimp exporter is exporting in the most compact format possible based on the files content.


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 8:01 pm  (#4) 
Offline
GimpChat Member

Joined: Jul 11, 2010
Posts: 349
How were you able to rule out the possibility that imagemagick is reading the file wrong?


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 8:53 pm  (#5) 
Offline
GimpChat Member

Joined: Feb 17, 2016
Posts: 8
bilbo9955 wrote:
How were you able to rule out the possibility that imagemagick is reading the file wrong?


Well imagemagick is having trouble reading bilev format....but that is why I want gimp to output RGBA

I just wrote a c++ program to inspect the format of the outputted pngs. The are definitely being output in different binary format.

I am simple looking to see if there is a way to force gimp to export in RGBA format.


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 9:26 pm  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12822
Maybe if you use the RIOT plugin for GIMP, you can have RIOT export to the proper format you are looking for. :)

http://luci.criosweb.ro/riot/

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Wed Feb 17, 2016 10:03 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: Nov 16, 2011
Posts: 5127
Location: Metro Vancouver, BC
I'm curious which options you're using with Gimp Export image as PNG?
Also have a look at the Save for Web plug-in.
Below is the Save for Web plug-in with the Gimp Export image as PNG dialog.

Image

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Thu Feb 18, 2016 1:11 am  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
Did three images:

- 200x200 white background
- add black square, export as PNG
- change square to red, export as PNG
- change square to white-red gradient, export as PNG

For imagemagick's identify command:
BiLev-Black.png PNG 200x200 200x200+0+0 8-bit DirectClass 731B 0.000u 0:00.000
BiLev-Red.png[2] PNG 200x200 200x200+0+0 8-bit DirectClass 738B 0.000u 0:00.000
BiLev-Gradient.png[1] PNG 200x200 200x200+0+0 8-bit DirectClass 8.62KB 0.000u 0:00.000

So it looks like it's the very same formatting all three cases.

More tries to show how grayscale and indexed images would show:
- reload White-Black imahe
- set to grayscale and export
- set to indexed and export

BiLev-Black.png[2] PNG 200x200 200x200+0+0 8-bit DirectClass 731B 0.000u 0:00.000
BiLev-Black-Grayscale.png PNG 200x200 200x200+0+0 8-bit PseudoClass 256c 425B 0.000u 0:00.000
BiLev-Black-Indexed.png[1] PNG 200x200 200x200+0+0 8-bit PseudoClass 2c 276B 0.000u 0:00.000

_________________
Image


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Thu Feb 18, 2016 5:19 am  (#9) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
Long boring post warning.

Going back to the OP's original information

Quote:
...I have a gimp xcf file with just black pixels and fully transparent pixels.
and later
...Color mode for both the xcf and the exported png is rgb, but imagemagick reads it as bilevel...


I can not reproduce Gimp xcf RGB image -> png bilevel.

Taking the first statement and making a RGB transparent canvas, painting on it with black. Two cases say, using the pencil tool for just black / transparent or the brush tool which will introduce some anti-aliasing.

Makes no difference as far as colorspace only to the depth of the alpha channel.
Imagemagick (IM) identify -verbose gives

for pure black and transparency
Type: PaletteAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8/1-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
alpha: 1-bit

and for a bit of anti-aliasing
Type: PaletteAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 1-bit
green: 1-bit
blue: 1-bit
alpha: 8-bit

Neither are bilevel, started as RGB and are still RGB

Similar pair of images but starting as a Grayscale / transparent Gimp canvas, does give bilevel
IM gives
Type: Bilevel
Base type: Bilevel
Endianess: Undefined
Colorspace: Gray
Depth: 8/1-bit
Channel depth:
gray: 1-bit
alpha: 1-bit
and
Type: Bilevel
Base type: Bilevel
Endianess: Undefined
Colorspace: Gray
Depth: 8-bit
Channel depth:
gray: 1-bit
alpha: 8-bit

A similar result, add a bit of anti-aliasing and the alpha bumps up to 8 bits.

As a test, starting with a grayscale black/transparent xcf image and changing the mode to RGB, a default png export gives a palettealpha rgb image.

I think the OP needs to give more information on how the original xcf image was made and what is expected
Quote:
..Is there a way I can force gimp to export to RGBA?..

AFAIK exporting from Gimp in RGB mode.
Is there something more expected? maybe truecolor 8 bits per channel? I do not thing that is possible with a black/transparent image.
You can force a 32 bit png using IM
convert in.png -colorspace sRGB PNG32:out.png but that gets the same as a Gimp RGB exported png, 1 bit per channel.


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Thu Feb 18, 2016 11:24 am  (#10) 
Offline
GimpChat Member

Joined: Feb 17, 2016
Posts: 8
I have tried all the possible exporting options checked and I get the same results.

here is the xcf and the exports I have done. I think from the file size, since the pixel size is the same, the encoding must be different.


Attachments:
rgba.png
rgba.png [ 8 KiB | Viewed 9374 times ]
bilev.png
bilev.png [ 3.66 KiB | Viewed 9374 times ]
numbers.xcf [46 KiB]
Downloaded 121 times
Top
 Post subject: Re: Force png export in RGBA
PostPosted: Thu Feb 18, 2016 1:02 pm  (#11) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
Here is a more visual analysis, Using XnViewMP and IM

Attachment:
comparison.jpg
comparison.jpg [ 80.5 KiB | Viewed 5687 times ]


Both bival.png and rgba.png are using RGB colorspace. For a bival image you would need to be in grayscale mode.

I can save your xcf to png using default settings and get exactly the same as your bival.png ie. an RGB png.

Adding colour of course makes a differnce, bival.png is PaletteAlpha while rgba.png is TrueColorAlpha and the red channel (colour used) is bumped up to 8 bits.

If you are trying to get a black/transparent png with 8 bits per channel, I know of no way to get that. Tried a few things with IM but always back to 1 bit per color channel + 8 bits alpha (there is anti-aliasing in your image)

Perhaps someone knows how to fake it.

OK, A conversion using Gimp and XnViewMP
XnView is never very happy with .xcf format so I exported your numbers.xcf as a .psd
That converts using XnViewMP to a 8 bit per channel + 8 bits alpha RGB png although still palettealpha

Attachment:
usingxnview.jpg
usingxnview.jpg [ 58.34 KiB | Viewed 5684 times ]


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Thu Feb 18, 2016 3:22 pm  (#12) 
Offline
GimpChat Member

Joined: Feb 17, 2016
Posts: 8
Just to reiterate (since the thread is getting long), I would like to be able to export the black/transparency image so it is the exact same format as the one with color.

Or is there a program (preferably command line) that could up convert from palette alpha to true color alpha?


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Fri Feb 19, 2016 12:45 pm  (#13) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
Do not know of a command line for this. Ask on the IM users forum, where they are extreamely helpful.

For the sake of completeness and with any number of caveats ( eg your multi-layer 0 to 9 xcf does not work for me) a black + transparent to truecolor png.

Start off with a new canvas, RGB and transparency
Add a character in black.
Export as a png
Gets you this, what you initially requested, an RGB png,

Image

but in type: PaletteAlpha

Instead of that: add some colour, in this case a strip of gradient. With those colours, exporting as a png will be in type: Truecolor

Image

If you then erase the strip of colour and export to png with default value Save color values from transparent pixels You get this. IM identify shows it as truecolor.

Image

After, you can always check if there is any alpha masked color using the eraser tool in 'anti-erase' mode.

How persistent this will be, I do not know. Might not survive posting here, so a file to check with IM is on my mediafire account http://www.mediafire.com/view/mi3do85qcqf69av/a.png


Top
 Post subject: Re: Force png export in RGBA
PostPosted: Fri Feb 19, 2016 6:43 pm  (#14) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
ap0c552 wrote:
I think from the file size, since the pixel size is the same, the encoding must be different.

No... the compression is different because there is no red stroke in one but the overall encoding is the same. For instance, two images that contains exactly the same number of black and white pixels:

Attachment:
bw-solid.png
bw-solid.png [ 368 Bytes | Viewed 5648 times ]
Attachment:
bw-spread.png
bw-spread.png [ 2.19 KiB | Viewed 5648 times ]


368 bytes vs 2.24K.

_________________
Image


Top
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group