PNG with transparency not showing

Ask for help and post your question on how to use XnView Classic.

Moderators: XnTriq, xnview

luiz_borges
Posts: 2
Joined: Thu Mar 15, 2007 2:19 pm

PNG with transparency not showing

Post by luiz_borges » Thu Mar 15, 2007 2:26 pm

I just discovered XnView, and I have a problem here with PNG files...
the transparency doesn't work with XnView 1.90.3...

Here is how its supposed to look (in IE it works flawless):
Image

Here is how it looks in XnView:
Image

I don't know if that is a bug or a misconfiguration, since it works on every other program I ever opened that image.

Thanks in advance,
Luiz Borges

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

Re: PNG with transparency not showing

Post by XnTriq » Thu Mar 15, 2007 11:20 pm

luiz_borges wrote:I don't know if that is a bug or a misconfiguration, since it works on every other program I ever opened that image.
FYI: IrfanView 3.99 and Corel PhotoPaint 11 don't like this image either.

Here's what TweakPNG 1.2.2 has to say about it:

Code: Select all

Chunk | Contents
------+--------------------------------------------------------
 IHDR | PNG image header: 512x512,
      |                   8 bits/sample,
      |                   grayscale+alpha,
      |                   interlaced
 pHYs | pixel size = 3149x3149 pixels per meter (80.0x80.0 dpi)
 iCCP | embedded ICC profile: [Photoshop ICC profile]
 gAMA | file gamma = 0.45454
 cHRM | chromaticities: WP(0.31269,0.32899),
      |                  R(0.63999,0.33001),
      |                  G(0.30000,0.60000),
      |                  B(0.15000,0.05999)
 IDAT | PNG image data
 IEND | end-of-image marker

User avatar
Clo
XnThusiast
Posts: 4441
Joined: Sun Oct 17, 2004 4:57 am
Location: Bordeaux, France
Contact:

Tweak…

Post by Clo » Thu Mar 15, 2007 11:48 pm

—> luiz_borges

:) Hello! Welcome aboard !

• I confirm, the display is broken in 1.90.3.

- I could display the image properly in Faststone (I don't like, but I've one for such tests)
and in “Imagine” Total Commander plug-in, but the transparency is replaced with white, that's normal for this soft.

• Like our Librarian said and showed, this image seems a bit tricky and special,
so I guess that Pierre has to tweak somes codes in order to support that…

:mrgreen: Kind regards,
Claude
Clo
Old user ON SELECTIVE STRIKE till further notice

luiz_borges
Posts: 2
Joined: Thu Mar 15, 2007 2:19 pm

Post by luiz_borges » Fri Mar 16, 2007 2:39 am

Thanks all for the quick reply, I hope this get fixed soon... :)

I don't know much about PNG encodings and I didn't know this image was tricky, I got that image in wikicommons if I'm not mistaken...
Anyway I think it's good that such image show up, so the code can get better... :)

PS: btw, this image works just fine with the Image Viewer of Windows XP...

Keep up with the good work,
Luiz Borges

User avatar
foxyshadis
Posts: 384
Joined: Sat Nov 18, 2006 8:57 am

Post by foxyshadis » Fri Mar 16, 2007 9:23 am

That's what it looks like if you turn off alpha channel processing. (Checked with this.) I guess xnview is getting confused somehow, since it normally reads them fine.

User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken » Fri Mar 16, 2007 11:47 am

It's funny, xnview shows only the RGB channel, while irfanview shows only the alpha channel. Image analyzer however, splits it into 2 images. I used PSP7 to combine those 2 images into a properly transparent image, then saved it from there.
http://allspark.net/cypherswipe/yang-grey-alpha.png <-greyscale with alpha transparency
http://allspark.net/cypherswipe/yang-full-alpha.png <-truecolor with alpha trans

User avatar
xnview
Author of XnView
Posts: 32081
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: PNG with transparency not showing

Post by xnview » Sat Mar 17, 2007 7:55 am

luiz_borges wrote:I just discovered XnView, and I have a problem here with PNG files...
the transparency doesn't work with XnView 1.90.3...

I don't know if that is a bug or a misconfiguration, since it works on every other program I ever opened that image.

Thanks in advance,
Luiz Borges
Ok, it's normal. It's a 8bits picture with a list of transparency color index. XnView support only 8bits + 1 transparency color or 32bits
Pierre.

robotriot

Post by robotriot » Thu May 31, 2007 10:01 pm

I've got a similar problem. Xnview seems to be the only app displaying the picture in the wrong way. Firefox for example displays it correctly.

But I wonder how it is possible that Xnview displays image information that really shouldn't be there. I created this picture by making a selection in Photoshop of the original image, copying and pasting it in a new, empty image with transparent background. I saved this as a PNG. Do you know why Photoshop includes this extra information in the image when copying a selection? I always thought it would only copy those pixels within the selection, and nothing outside of that. It's also really ineffective if those extra pixels are saved, making the files unnecessarily large.

http://robotriot.hokuten.net/trash/gestaeng01.png

User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken » Thu May 31, 2007 10:27 pm

No idea why photoshop includes that extra stuff, never use the prog myself. It'd be interesting if you tried repeating the experiment, but saving it as a gif instead of a png. Photoshop has had issues with pngs in the past, it wouldn't surprise me if it's doing it again.

As far as why it displays differently, it has an alpha channel transparency that xnview isn't showing. Image analyzer doesn't compose pngs with alpha channels properly either, but it does show the alpha channel as a seperate image. When I opened your pic in IA, it shows the 24bit image with all the extra data and no transparency, and an 8bit alpha channel transparency mask that (when applied) would make all the extra stuff transparent.
http://allspark.net/cypherswipe/forklift-photo.png
http://allspark.net/cypherswipe/forklift-alphamask.png
If you open the photo in any editor capable of applying masks, and use the second image as the mask, it'll recreate the transparency.

Try saving the image again, but use the "save for web" option.

robotriot

Post by robotriot » Thu May 31, 2007 11:45 pm

Saving as a GIF produces correct transparency. Using Save for Web and PNG file format produces the same results as before (unnecessary extra data). I've reproduced this each and every time with the photos I'm working on currently. Really strange.

User avatar
Drahken
Posts: 884
Joined: Sun Apr 10, 2005 4:29 pm

Post by Drahken » Fri Jun 01, 2007 6:55 am

If I compose it in paint shop pro, it removes the extra crap. When the image is viewed in a prog that doesn't properly support alpha transparency, the transparent parts of the image are plain black. The filesize is another giveaway. Your photo with transparency is 309k, the photo without the alpha mask is 280k, the alpha transparency created by PSP is only 185k (and if I knock it down to 256 colors /w single color transparency (like a gif), it's only 50k).
http://allspark.net/cypherswipe/forklift-a.png <-alpha trans, courtesy of PSP
http://allspark.net/cypherswipe/forklift-c.png <-256 color

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

Post by XnTriq » Sat Jun 02, 2007 8:50 am

XnView v1.9X displays the image perfectly correct. Is the Use transparent index (<=8bits) or alpha channel setting (Tools » Options... » View » View) turned off in your installation, robotriot? If so, XnView is actually just revealing the mess that's left behind by Photoshop.

I ran into this problem myself while trying to improve my skills in background masking, and if it hadn't been for XnView, I probably would never have become aware of this “hidden data” flaw.

I doubt the problem is caused by Adobe's PNG file format filter (Png.8bi). Even exporting with SuperPNG (freeware) or the plug-in version of PNGOUT (shareware) doesn't get rid of all excess image information.

In the two combined screenshots below you can see how Corel PHOTO-PAINT v11 displays the file:
  • Image [ Zoom ]
    Top: Marquee Visible
    Bottom: Mask Overlay
More examples of Photoshop's dirty little secret: Finally – just for the record – here's TeakPNG's take on gestaeng01.png:

Code: Select all

Chunk | Contents
------+------------------------------------------
 IHDR | PNG image header: 687x486,
      |                   8 bits/sample,
      |                   truecolor+alpha,
      |                   noninterlaced
 pHYs | pixel size = 2835x2835 pixels per meter (72.0x72.0 dpi)
 iCCP | embedded ICC profile: [Photoshop ICC profile]
 gAMA | file gamma = 0.45454
 cHRM | chromaticities: WP(0.31269,0.32899),
      |                  R(0.63999,0.33001),
      |                  G(0.30000,0.60000),
      |                  B(0.15000,0.05999)
 IDAT | PNG image data
 IEND | end-of-image marker

wolfgangbeyer
Posts: 23
Joined: Sun Jun 10, 2007 12:48 pm
Location: Munich
Contact:

Post by wolfgangbeyer » Fri Jun 22, 2007 1:11 pm

Hi, XnTriq,
XnTriq wrote:XnView v1.9X displays the image perfectly correct. Is the Use transparent index (<=8bits) or alpha channel setting (Tools » Options... » View » View) turned off in your installation, robotriot?
I just had the same problem with a 32 bit PNG, and I solved it by turning this option on. So I like to ask: Is there any reason to turn off this option? Wouldn't it be better to have off as default setting?
Wolfgang Beyer
www.wolfgangbeyer.de

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

Post by XnTriq » Fri Jun 22, 2007 8:30 pm

Hello wolfgangbeyer :)

Well, currently Pierre is thinking about moving this very option to the menu (see topic “Transparency & alpha”).
But there are quite a few other settings that have direct or indirect influence on how transparency (especially in PNGs) is displayed:
  • View
    • Show Mask
  • Tools » Options...
    • General » Read/Write » Read » PNG
      • Parameters
        Compose image with transparency
        Compose image with alpha (32bits)
    • View » View
      • Auto Image Size
      • Background Colour
      • Use transparent index (<=8bits) or alpha channel
        Xyzzy (Options' descriptions for 1.82) wrote: “For files with depth <= 8bits per pixel (fe. GIF), show transparent/alpha masked ??? areas in background color. Note: Thumbnails in Browser always show transparency, also for files with depth greater than 8 bit.”
Frankly, the way XnView handles tranparency is confusing to a lot of people (including myself, I might add). I've adressed this issue several times in the past — to little or no avail. What's needed is a unified method for all formats that support transparency:
  • 32-bit BMPs
  • Windows Cursors (.CUR) & Animated Cursors (.ANI)
  • 8-bit Windows Icons (.ICO)
  • 32-bit Windows Icons (.ICO)
  • GIFs & Animated GIFs
  • 8-bit (palette-based) PNGs with binary transparency
  • 8-bit RGB-A PNGs (alpha-channel)
  • 24-bit PNGs with binary transparency
  • 32-bit RGB-A PNGs (including those with “multi-level transparency”)
  • Photoshop (.PSD)
  • TARGA (.TGA)
  • TIFF
Again, being able to toggle transparency is a great feature. I know of only one other program which allows me to do so, and that's GraphicsGale.

wolfgangbeyer
Posts: 23
Joined: Sun Jun 10, 2007 12:48 pm
Location: Munich
Contact:

Post by wolfgangbeyer » Sat Jun 23, 2007 12:58 pm

I made a typing error. I would like to ask: Wouldn't it be better to have on as default setting?

Hi, XnTriq, thank you for your detailed answer, but I understand only very few. In XnView transparency is not edited but only displayed, so far I understand. So I don’t understand the option Tools » Options » General » Read/Write » Read » PNG » Parameters » Compose ...

And what is displayed if "For files with depth <= 8bits per pixel (fe. GIF), show transparent/alpha masked ??? areas in background color" is turned off? I have difficulties to understand, how this can be a description of an option called "Use transparent index (<=8bits) or alpha channel" at all. What are the disadvantages or the advantages to turn this option off? I my case off seems to display nonsense.

Or does off means to ignore the transparent/alpha maske and display the hidden colors in the RGB channels, which are actually intended not to be visible due to the transparency? Than off as default seems nonsense for me.
Wolfgang Beyer
www.wolfgangbeyer.de

Post Reply