What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Converting image with semi-transparent pixels to 256 colors


Darkloke

New Member
Messages
3
Likes
0
Greetings. I hope you could help me with the following subject.

I am trying to find a "perfect" way (for myself) to convert an image from RGB PNG with transparency to 256 indexed colors format. I am trying to mod a very old game and images there support only 256 colors format with palettes. Specifically i am interested what things i could try to "smooth" out borders with semi-transparent pixels... what methods or tricks could help so the indexed image could resemble original as maximum as possible.

When i am saying above "indexed image could resemble original as maximum as possible" i mean this is only regarding borders with semi-transparent pixels. Since my images are quite small, we arent talking about color losing problem in conversion process, this is not a subject of my question.

Here some thoughts and things i already tried.

1. First of all i use layer mask from transparency -> threshold -> 1 to receive "original black matte" from the existing transparency of the original image. As i understand doing so allows to me to preserve maximum original image information before next step.
2. Reduce image to 44x52 using bicubic (smooth gradients) interpolation. That reduce method was pure my choice based only on my observations, i personally dont like additional sharpness from other methods.
3. Duplicate layer. Trick about duplicating layer as well as thresholding layered mask i randomly got from adobe community forum here. In my case i have only 1 duplicate of the layer, but the question of "how many of them should be" is still unanswered for me.

This are the base steps i do. And now i usually open history tab and switch between last two steps (duplicate layer and indexed colors) to see how resulting image changes from the original. This is the stage where i think i have to do something else to smooth the difference. All other operations i tried i made on the "bottom" layer, so the "top" one could "smooth" results. Tried median, various blurs, defringe and something else.

I hope i stated my question more or less clearly... And here are images i am now experimenting with.

Assassin's Dagger.png

Ax.png

Crookhorn Longbow.png

Longsword.png

Quarterstaff.png
 
Greetings. I hope you could help me with the following subject.

I am trying to find a "perfect" way (for myself) to convert an image from RGB PNG with transparency to 256 indexed colors format. I am trying to mod a very old game and images there support only 256 colors format with palettes. Specifically i am interested what things i could try to "smooth" out borders with semi-transparent pixels... what methods or tricks could help so the indexed image could resemble original as maximum as possible.

When i am saying above "indexed image could resemble original as maximum as possible" i mean this is only regarding borders with semi-transparent pixels. Since my images are quite small, we arent talking about color losing problem in conversion process, this is not a subject of my question.

Here some thoughts and things i already tried.

1. First of all i use layer mask from transparency -> threshold -> 1 to receive "original black matte" from the existing transparency of the original image. As i understand doing so allows to me to preserve maximum original image information before next step.
2. Reduce image to 44x52 using bicubic (smooth gradients) interpolation. That reduce method was pure my choice based only on my observations, i personally dont like additional sharpness from other methods.
3. Duplicate layer. Trick about duplicating layer as well as thresholding layered mask i randomly got from adobe community forum here. In my case i have only 1 duplicate of the layer, but the question of "how many of them should be" is still unanswered for me.

This are the base steps i do. And now i usually open history tab and switch between last two steps (duplicate layer and indexed colors) to see how resulting image changes from the original. This is the stage where i think i have to do something else to smooth the difference. All other operations i tried i made on the "bottom" layer, so the "top" one could "smooth" results. Tried median, various blurs, defringe and something else.

I hope i stated my question more or less clearly... And here are images i am now experimenting with.

View attachment 149175

View attachment 149176

View attachment 149177

View attachment 149178

View attachment 149179
Do you need the final file to be in PNG-8 format with embedded variable levels of transparency? If yes, Photoshop does not support PNG-8 with multiple levels of transparency, as I understand. It only allows for one encoded color table value to be fully transparent.

If you are simulating limited total colors with multiple levels, I am pretty sure that can be done PNG-24, yet I did not want to go down that path if you need PNG-8 format.

Other software does support PNG-8 with multiple levels of transparency. ImageMagick is one such program.

Let me know what path you plan to take.
John Wheeler
 
Do you need the final file to be in PNG-8 format with embedded variable levels of transparency? If yes, Photoshop does not support PNG-8 with multiple levels of transparency, as I understand. It only allows for one encoded color table value to be fully transparent.
No, the final format format is 8 bit PNG with palette. I convert it then into game specific file format and i doubt converter would "understand" anything else except "classic" format with indexed colors (like PNG, GIF, BMP, PCX, etc.).
 
Hi Darkloke
Suppose you must convert with multiple levels of transparency in a PNG-8 format. In that case, I think you have to go beyond Photoshop for that capability and I mentioned some options in a prior post.

Photoshop can easily create a PNG-8 file with lower color tones on the edge to simulate transparency (which may not look good depending on the background upon which the image is overlayed).

You use the Save for Web command, and they have an option for dithering transparency (which is just changing the tone of solid colors where there was previously transparency.

I have two screenshots, the first showing the look of full channel transparency with PNG-24 and the other showing the outputting preview with one of the three transparency dithering options.

PNG-24 output preview:
Screenshot 2025-01-22 at 12.18.44 PM.jpg

PNG-8 preview with transparency "dithering"
Screenshot 2025-01-22 at 12.20.23 PM.jpg

Hope this incremental information is helpful
John Wheeler
 
Hi Darkloke
Suppose you must convert with multiple levels of transparency in a PNG-8 format. In that case, I think you have to go beyond Photoshop for that capability and I mentioned some options in a prior post.
Yes, thanks. It was interesting for me to know that there are possibilities to save in PNG-8 preserving multiple levels of transparency, but regretfully that format wont suit my needs. Interesting anyway.

Photoshop can easily create a PNG-8 file with lower color tones on the edge to simulate transparency (which may not look good depending on the background upon which the image is overlayed).
You use the Save for Web command, and they have an option for dithering transparency (which is just changing the tone of solid colors where there was previously transparency.
I have two screenshots, the first showing the look of full channel transparency with PNG-24 and the other showing the outputting preview with one of the three transparency dithering options.
Yeah, i know about "save for web" option, but the problem here is "matte". While white matte for example looks ok on transparent background, it looks "wrong" on the final image. I am using a cyan color as a "chromakey", i.e. color for transparency for 256 colors. So i have to do something not using any matte options. As i understand converting to 256 colors thresholds the transparency with the default 128 value.

Also i dunno... May be my final images are already good enough to use for my purposes. May be i just need some opinions from the outside (esp. from the professionals) to be sure in my work.

Here is for example the bow done with my method described in 1st post. The second one is done with using "white" matte option - it was ok on transparent background, but on "chromakey" it "fails".

ps1.png

ps2.png
 

Back
Top