Editing an images loses its transparency

Bugs found in XnView Classic. Please report only one bug per topic!

Moderators: XnTriq, helmut, xnview

User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Editing an images loses its transparency

Post by Brother Gabriel-Marie »

This is a bug that's been in XnView for years.

If I have a png or gif with a transparent background and edit the image in XnView, either by changing its color mode or anything else, when it is saved, the transparent background is changed to white.

The problem persists in version 1.996
User avatar
xnview
Author of XnView
Posts: 43328
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Editing an images loses its transparency

Post by xnview »

Do you changed from color in RGBA?
Pierre.
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

Hi, Mr. XnView. If I change from color RGB to greyscale, the transparent background turns to white. The thumbnail also loses the transparency.

I can confirm this because it is even white when I open the files in Photoshop. I had the same problem on my old XP as I do now in Windows 7 x64.
User avatar
xnview
Author of XnView
Posts: 43328
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Editing an images loses its transparency

Post by xnview »

8bits picture has no transparency mask in Xnview
Pierre.
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Editing an images loses its transparency

Post by XnTriq »

Workaround:
  • Download logo.png (32-bit RGBA) and open it in XnView MP.
  • Go to Image » Change color depth... and select 24 bits » OK.
  • Go to Image » Change color depth... again and select Greyscale [256] » OK.
  • Save the result as greyscale.png.
  • Open logo.png once more and go to Image » Extract channel » Alpha.
  • Save the result as mask.png.
  • Go to Tools » Batch convert... and specify the following settings:
    • Input
      • greyscale.png
    • Actions
      • Image » Add mask
        • Mask: [mask.png]
        • [√] Use mask as alpha
    • Output
      • Format: [PNG]
greyscale_result.png is a achromatic/desaturated/grayish version of logo.png.
  • Image Image Image Image
    Left to right: logo.png + greyscale.png + mask.png + greyscale_result.png
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

8bits picture has no transparency mask in Xnview
I'm a little confused - so when I change a RGB file to Greyscale in XnView, then is it supposed to lose its transparency? I don't want it to do that. I am forced to open the file in Photoshop to change the colours. I don't want to do that either.

And it's not just the masking for the thumbnail. If I change it to greyscale, the transparency is completely lost - I can see it lost when I edit it in Photoshop. I have to edit the file again in order to fix it.

Also, an 8bit image with transparency does not display its transparency in XnView in "View" mode, although it *does* in thumbnail mode.

It is the same problem either with an 8 bit image OR a 16bit image.

If the thumbnail does not show its transparency, which it doesn't at first, it *will* if you a "rebuild thumbnail" on the file (or files in the folder).

In my (humble) opinion, whether 8bit OR 16bit, if I change the colour from rgb to greyscale, the transparency should be preserved, AND the thumbnail should be automatically rebuilt.

Image
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Editing an images loses its transparency

Post by XnTriq »

Brother Gabriel-Marie wrote:Also, an 8bit image with transparency does not display its transparency in XnView in "View" mode, although it *does* in thumbnail mode.
This is a known limitation. It was fixed in XnView v1.97 for 8-bit color PNGs + alpha-channel transparency, but the issue persists with grayscale + alpha channel.
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

@XnTriq, thanks for the confirmation (I *knew* I wasn't crazy), and the for the info (and for fixing my image-link).
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

I use XnView to view png files all the time. Sometimes the png files will show the transparency in the thumbnail, sometimes they don't. Most of the time they don't show the transparency in preview mode. And this happens even if I don't edit them in XnView.

I am having this problem with png files made by exporting from Adobe Illustrator CS5 (Windows 7 Pro x64; 16gb RAM; XnView 2.10)

If I rebuild thumbnails, the transparency seems to get fixed on the thumbnails, but I have to do it over and over to the same images. And that doesn't help the preview.

Is there some setting somewhere to make the transparency rendering consistent?
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

Hi folks! I'm back to this again; hoping circumstances are okay now to get a fix.
Version 2.25

So I have some png files with transparent backgrounds.
24 bit RGB

When I adjust the gamma/contrast of the image and save it in xnview, all the transparency is turned to white.
This problem is in the image file itself - not just the preview.
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Editing an images loses its transparency

Post by XnTriq »

Brother Gabriel-Marie wrote:So I have some png files with transparent backgrounds.
24 bit RGB

When I adjust the gamma/contrast of the image and save it in xnview, all the transparency is turned to white.
This problem is in the image file itself - not just the preview.
Could you post a sample, Br. Gabriel-Marie?
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

Ak! I tried to upload my sample files, but the forum says
"Image file type mismatch: expected extension jpg but extension png given" - I've had that before. PITA.
If I upload them to imgur, the transparency gets scrapped there, too.
Maybe I could email them to you...

But this is an example of sorts:
screenshot_XnView (XnView for Windows) [xnview]_009.png
screenshot_XnView (XnView for Windows) [xnview]_009.png (22.35 KiB) Viewed 3673 times
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Editing an images loses its transparency

Post by cday »

Brother Gabriel-Marie wrote:Ak! I tried to upload my sample files, but the forum says
"Image file type mismatch: expected extension jpg but extension png given" - I've had that before. PITA.
Might upload successfully in a ZIP (or RAR) archive?
User avatar
Brother Gabriel-Marie
Posts: 286
Joined: Thu Aug 23, 2007 2:33 pm
Location: United States

Re: Editing an images loses its transparency

Post by Brother Gabriel-Marie »

Okay, I had to use different images.
Here is a zip file.
Attachments
transparency_loss.zip
(501.36 KiB) Downloaded 111 times
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Editing an images loses its transparency

Post by XnTriq »

I can't reproduce :?

What I done did:
  1. Fired up XnView v2.25
  2. Opened opossum.png
  3. Went to Image » Adjust » Brightness/Contrast/Gamma/Balance...
  4. Set Contrast to 127
  5. Set Gamma correction to 0.50
    1. Went to File » Export... » PNG to save opossum.png as opossum_export.png
    2. Went to File » Save to overwrite opossum.png
The alpha channel transparency of the resulting files (opossum_export.png + overwritten opossum.png) is left intact and both files are bit-for-bit identical.

Code: Select all

X:\>FC /B opossum.png opossum_export.png
Comparing files opossum.png and opossum_export.png
FC: no differences encountered
What are your settings in Tools » Options... » Read/Write » Write » PNG » Parameters, Br. Gabriel-Marie?
Post Reply