How to set PNG transparency color?
Moderators: XnTriq, helmut, xnview
-
- XnThusiast
- Posts: 2010
- Joined: Wed Mar 17, 2004 8:33 pm
- Location: Sarasota Florida
How to set PNG transparency color?
I searched the forum but didn't find a clear answer to this:
In the PNG options there is a place to enter the palette "entry" for the transparency color.
If I want a specific color in my image to map to transparent (say, magenta), what value do I put in that PNG option?
Perhaps it would be good to display a palette in that dialog?
In the PNG options there is a place to enter the palette "entry" for the transparency color.
If I want a specific color in my image to map to transparent (say, magenta), what value do I put in that PNG option?
Perhaps it would be good to display a palette in that dialog?
John
-
- Moderator & Librarian
- Posts: 6376
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Hi JohnFredC!
If it's a true color image you'll have to reduce the color depth first.
To determine an index number, go to Image » Edit Colormap… (in View mode).
When you move the mouse cursor over a palette entry, the color's index number, its RGB value & the HTML/hex code are displayed in the list box on the right.
If it's a true color image you'll have to reduce the color depth first.
To determine an index number, go to Image » Edit Colormap… (in View mode).
When you move the mouse cursor over a palette entry, the color's index number, its RGB value & the HTML/hex code are displayed in the list box on the right.
-
- XnThusiast
- Posts: 2010
- Joined: Wed Mar 17, 2004 8:33 pm
- Location: Sarasota Florida
-
- Posts: 8705
- Joined: Sun Oct 12, 2003 6:47 pm
- Location: Frankfurt, Germany
A while back I've written up an FAQ that describes the creation of images with transparency. The FAQ is not finished, yet, here a part which might be useful:
Step 4: Determine the transparent colour
In some images, the background colour is different to all the other colours and it's obvious which is the background colour. But in some images it might be not so obvious.
In this case you can use the colour info to determine the index of the background colour:
a) Select menu "View > Display Colour Information" The mouse cursor's shape will change to a pipette. Also next to the mouse cursor, the index, the RGB colour and Hex value of the colour will be displayed.
b.) Move the mouse cursor to an area fo your image which is the background.
c.) Now remember the index of the colour which ranges from 0..255
Step 5: Set the transparent colour
Now that you have reduced size and set reduced colour depth of your image, you finally set the transparent colour of your image.
For setting the transparent colour (assuming that XnView and your image are still open)
a.) Open the "Colour map" dialog using menu "Image > Edit colour map"
b.) Click onto the colour with the index that you have determined above in Step 3.).
c.) If you have used an odd colour (e.g. magenta) as background, double click onto the selected colour. Now you can change the colour of your transparent colour to whichever colour you like (actually it doesn't matter much, since the colour will be transparent in real life.).
d.) Set the checkbox "Use transparent colour"
Note:
Make sure you first perform b.) and then d.), otherwise the transparent colour will not be set properly.
Step 4: Determine the transparent colour
In some images, the background colour is different to all the other colours and it's obvious which is the background colour. But in some images it might be not so obvious.
In this case you can use the colour info to determine the index of the background colour:
a) Select menu "View > Display Colour Information" The mouse cursor's shape will change to a pipette. Also next to the mouse cursor, the index, the RGB colour and Hex value of the colour will be displayed.
b.) Move the mouse cursor to an area fo your image which is the background.
c.) Now remember the index of the colour which ranges from 0..255
Step 5: Set the transparent colour
Now that you have reduced size and set reduced colour depth of your image, you finally set the transparent colour of your image.
For setting the transparent colour (assuming that XnView and your image are still open)
a.) Open the "Colour map" dialog using menu "Image > Edit colour map"
b.) Click onto the colour with the index that you have determined above in Step 3.).
c.) If you have used an odd colour (e.g. magenta) as background, double click onto the selected colour. Now you can change the colour of your transparent colour to whichever colour you like (actually it doesn't matter much, since the colour will be transparent in real life.).
d.) Set the checkbox "Use transparent colour"
Note:
Make sure you first perform b.) and then d.), otherwise the transparent colour will not be set properly.
See throught Background
Hi I am having a very hard time changing my background color fon my image from a green background to a "see through" background. Is it anybody that can help me with this
-
- Posts: 884
- Joined: Sun Apr 10, 2005 4:29 pm
Image->convert to colors (however many colors you want, adaptive is generally better than dithered)
Image->edit color map
Select the green square, then go over and check the little box that says transparency.
Click "ok", and the areas that were formerly green will now appear whatever background color is set in the program options (but it's actually transparent, just save the image and open it in your web browser to see.)
If you want to change the background color in the program, go tools->options->view and you'll see a box for background color. Keep in mind that this color is only used in the program, and has no effect on the images themselves.
Image->edit color map
Select the green square, then go over and check the little box that says transparency.
Click "ok", and the areas that were formerly green will now appear whatever background color is set in the program options (but it's actually transparent, just save the image and open it in your web browser to see.)
If you want to change the background color in the program, go tools->options->view and you'll see a box for background color. Keep in mind that this color is only used in the program, and has no effect on the images themselves.
Oh the feuhrer, oh the feuhrer, oh the feuhrer's nipples bonk!
-
- Posts: 291
- Joined: Thu Oct 12, 2006 2:45 pm
I want to bring this topic up again, as IMHO the 1.90beta2 Export wizard shall be able to set the transparency (as checkbox "set transparency for palette entry 0" or - my varoured solution - by popping up the color palette and selecting the color that shall be transparent) when 256colors are selected from the drop down. Thoughts?
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Yes, right, i'll try to add it in the 1.90GeorgD wrote:I want to bring this topic up again, as IMHO the 1.90beta2 Export wizard shall be able to set the transparency (as checkbox "set transparency for palette entry 0" or - my varoured solution - by popping up the color palette and selecting the color that shall be transparent) when 256colors are selected from the drop down. Thoughts?
Pierre.
-
- Posts: 291
- Joined: Thu Oct 12, 2006 2:45 pm
-
- Posts: 32
- Joined: Tue Dec 20, 2005 11:01 am
- Location: between Faye and Edward, approximately by now
set transparency value to palette entry
i expect this is a redundant topic. if so; if there's a FAQ please FWD me as i couldn't find anything. i found the following to be the "closest match"
http://newsgroup.xnview.com/viewtopic.php?t=5595
QUESTION:
what is the function of the "option" parameter:
File
.Write
. .GIF
. . .set transparency value to palette entry
thanks.
(i believe i have a similar issue w/ png format, however it appears to be covered, i think, in the other thread i've cited above)
http://newsgroup.xnview.com/viewtopic.php?t=5595
QUESTION:
what is the function of the "option" parameter:
File
.Write
. .GIF
. . .set transparency value to palette entry
thanks.
(i believe i have a similar issue w/ png format, however it appears to be covered, i think, in the other thread i've cited above)
Have a go at these texts featuring graphics and imaging, please.
-
- Posts: 884
- Joined: Sun Apr 10, 2005 4:29 pm
GIFs, certain PNGs, and a few othe formats have a palette of only 256 colors (vs the 16 million in JPG, certain other PNGs, and most other formats). GIF has single color transparency only (PNG can have either single color transparency or alpha transparency). If you go into the options and set transparency to palette entry 50, then whichever of the 256 colors in your image is located in palette entry 50 will be saved as transparent. This is not a particularly useful option, since i requires you to know exactly which palette slot white (or whatever color you want to be transparent) is in. It's much better to set transparency from the image->edit colormap option. (If the image is currently in truecolor mode, you need to go image->convert to colors to make the edit colormap option work.)
-
- Posts: 2
- Joined: Wed Jun 20, 2007 1:54 pm
Hi to all,
On this very same topic, but a little harder question. If I want to batch convert hundreds of pictures which have a consistent background and have them with a transparent background. Is there any possibility to do that ?
I shall first convert them to PNG but then ???
I know that as the background can vary between picture there might be some difficulties. But there should be a way!!!
I have set up some examples here: http://intranet.easyviz.com/gallery2/ma ... itemId=867
On this very same topic, but a little harder question. If I want to batch convert hundreds of pictures which have a consistent background and have them with a transparent background. Is there any possibility to do that ?
I shall first convert them to PNG but then ???
I know that as the background can vary between picture there might be some difficulties. But there should be a way!!!
I have set up some examples here: http://intranet.easyviz.com/gallery2/ma ... itemId=867
-
- Posts: 2
- Joined: Wed Jun 20, 2007 1:54 pm
-
- Moderator & Librarian
- Posts: 6376
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
arnaud wrote:If I want to batch convert hundreds of pictures which have a consistent background and have them with a transparent background.
- Wikipedia: Chroma key
- photo.net Forums: batch jpeg to tiff with backround removed
- Photoshop Scripting Community Forum: Batch Image Manipulation Including Chroma Key - Any Advice?
- Jeff Geerling: Keying Out Backgrounds in Photoshop
- Digital Anarchy: Primatte Chromakey » Work with Actions and Batching
- Stepok: Recomposit » Batch Processing