Page 1 of 1

"Convert to colors" & transparency

Posted: Sun Sep 04, 2011 1:10 pm
by dma_k
I've got a question related to one I've asked before.

What I want to achieve is the following: Obviously, when you do color reduction, the transparent color may conflict with color already used in the picture. It would be nice if there is any ability to "fix" ("stick") this color across color reduction functions.

Suppose I have an ICO image and I apply Image → Convert to colors. What I see is that transparent color is replaced with while color. My first question is: Why white? How to customize and make it e.g. blue?

The next step I choose Image → Edit palette and I enable the transparency with transparent color with index = 0. Now I want to reduce further colors, but with preserving the transparent color.
  • When I do Image → Convert to colors I loose transparent color. Pity.
  • When I do File → Export, this function also seems to ignore the just set transparent color.
My second question is: how to "preserve" the transparent color?

Re: "Convert to colors" & transparency

Posted: Tue Sep 06, 2011 12:06 am
by Drahken
re file->export: Assuming that you export to gif or png, it does actually save the transparent color, it's just that it doesn't -show- as transparent in the preview. To confirm that it's using the right transparent color, or to set a diff color, you can click the "set transparency color" button on the save dialog, next to the # of colors dropdown.

Re: "Convert to colors" & transparency

Posted: Tue Sep 06, 2011 2:27 pm
by dma_k
Drahken wrote:re file->export: Assuming that you export to gif or png, it does actually save the transparent color, it's just that it doesn't -show- as transparent in the preview. To confirm that it's using the right transparent color, or to set a diff color, you can click the "set transparency color" button on the save dialog, next to the # of colors dropdown.
That is my point: I don't want to use "Set transparency color" button in export dialog, because it is already defined. Does it sound reasonable?

Let's take a real example: favicon.gif:
  • Open this GIF in xnview, call File → Export.
  • Select Gif tab, choose 64 colors, save to favicon2.gif.
  • Open favicon2.gif. The transparent color is gone.
So, what sequence will decrease the number of colors but still preserve the transparency for the pixels that were transparent (and will NOT make other pixels transparent)?

Re: "Convert to colors" & transparency

Posted: Tue Sep 06, 2011 8:23 pm
by Drahken
If you're changing the # of colors in the export dialog, then THAT is what's causing your image to lose transparency.

...also, why would you want to "further reduce the colors"?? Just drop them from 24bit straight down to 64 or whatever, there's no advantage to dropping them down to 256 and then dropping them again to 64.

Every time you reduce colors (no matter how you do it), you will have to re-set the transparent one. Even increasing colors, or (very strangely) "changing" to the same number of colors erases the transparency setting. (ie, Take a pic with 8 colors & no dithering, "change" it to 8 colors with no dithering (ie, no actual change should take place), and the transparency goes out the window.)

If you open image->convert to colors->64->edit palette->set transparency->export->gif->done, then open the image you just saved, it will retain the transparency you set (even though the preview in the export dialog won't show it).



Also, since you're not changing colors in the export dialog, you can simply file->save or file->save as. However, before doing that, go into options->read/write->write->gif and make sure that the "set transparency value" option is UNchecked. If it's checked, then it will always save transparency as the entry listed, regardless of what you set it as while editing.

Re: "Convert to colors" & transparency

Posted: Wed Sep 07, 2011 12:53 pm
by dma_k
Drahken, thanks for your reply. I think, we have common understanding of the steps, and I fully understand your comments.
Drahken wrote:Every time you reduce colors (no matter how you do it), you will have to re-set the transparent one.
This is the only and the central point of this post. Why I have to? Maybe there is a good reason to reset the transparency color (if you know it – let me know), but I think more practical is to preserve it (you may call it "stick" or "reserve") and that is what I expect during the color reduction operation. And the real problem is that during this operation the colors that are almost the same might be reduced to one: e.g. if transparent color was 0xFFFFFF, and another color 0xFEFEFE was reduced to it, then choosing transparent color 0xFFFFFF will also make other pixels transparent, which initially haven't been! The correct behaviour would be to switch the transparency to unique unused color in the palette (say 0xFF0000) and let white be white :) This behaviour can easily be controlled by preference option ([x] Preserve transparency color if possible) in order not to break backward-compatibility.

This is my personal opinion as an end user, perhaps for you the current bahaviour is OK. I wonder, how you deal with above situation then?

Re: "Convert to colors" & transparency

Posted: Wed Sep 07, 2011 1:56 pm
by Drahken
I have no idea why it reverts the transparent color when you change. I could understand when you reduce colors because the formerly transparent color may cease to exist (or some other color may get "collapsed" into the transparent one when you reduce, thus making parts of the image transparent that you didn't -want- transparent), but there's no reason for it to revert when you INcrease colors (which it does), and especially no reason when you "change" colors without actually changing them (ie, convert an 8 color non-dithered image to an 8 color non-dithered image).
My only guess is that the program recalculates all colors every time you "change" the color depth, even when it doesn't really need to. I don't however know whether it -has- to be that way for some reason, or if it's just way to complicated to do it a different way, or if the current way was merely some sort of oversite. We'll have to wait for an official response for the answer to that question.


Personally, I never use xnview to make transparent images (unless I'm resizing/converting/etc a pic which had transparency to begin with), I use a dedicated image editor (paint shop pro v7 is my personal fav). Merely choosing a transparent color is far too clumsy & invariably results in messy looking pics. With an image editor, you can use tools like paint brushes to smooth out blips, paint areas you didn't want transparent a different color, etc. Also, image editors let you use the much better alpha channel transparency.
Xnview is a great image viewer, editor, and catalogging tool, but it was never designed to be a fully functioning editor, so there are times when it's still best to use some other program.

Re: "Convert to colors" & transparency

Posted: Fri Sep 09, 2011 12:05 am
by dma_k
Good that we have agreed, that there is a field for improvement here. Indeed xnview can't compete with powerful editors, but it does not prevent it from doing tiny things perfectly :)

Re: "Convert to colors" & transparency

Posted: Fri Nov 23, 2012 2:15 am
by XnTriq
Some image editors can indeed preserve transparency (alpha channel » palette index) during color depth reduction — even to B&W with dithering.
  • Image
Macromedia Fireworks v4.0.2 (“Export Preview”):
Adobe Photoshop v6.0.1 (“Save for Web”):
Gamani's GIF Movie Gear, for example, is a more affordable alternative.

Related topics: