PNG Resizing Transparency Issue

Reported bugs that have been closed and/or resolved

Moderators: XnTriq, helmut, xnview, Dreamer

kytrin
Posts: 5
Joined: Thu Jun 17, 2021 2:49 pm

PNG Resizing Transparency Issue

Post by kytrin »

Hi, I'm running into a problem where when I attempt to batch resize png images with transparent backgrounds, some of them are converting with green or black backgrounds instead and I cannot figure out why. I am not doing anything fancy with them other than increasing their size enough to work with my mapmaking software, and the bulk of my map assets convert just fine, so I am doubly at a loss.

My settings for conversion are a simple resize from 100% to 142.86% with everything else left at default.

I have tried restarting the software, restarting my system, updating drivers, re-downloading the image pack, re-running the conversion several times with various settings... all to no effect.

Does anyone have any thoughts for me on this? I really need my transparent backgrounds to properly build maps. Thanks!
User avatar
xnview
Author of XnView
Posts: 43444
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: PNG Resizing Transparency Issue

Post by xnview »

could you post a file?
Pierre.
kytrin
Posts: 5
Joined: Thu Jun 17, 2021 2:49 pm

Re: PNG Resizing Transparency Issue

Post by kytrin »

xnview wrote: Thu Jun 17, 2021 4:04 pm could you post a file?
Yeah sure thing. What are you looking for exactly?
User avatar
Rick
Posts: 233
Joined: Sat Oct 08, 2005 4:10 pm
Contact:

Re: PNG Resizing Transparency Issue

Post by Rick »

Post one that is giving you fits. I would guess attaching it rather than inline would be best
--
Rick
kytrin
Posts: 5
Joined: Thu Jun 17, 2021 2:49 pm

Re: PNG Resizing Transparency Issue

Post by kytrin »

Okay here is the before and after as previewed in batch converter:

Before: https://ibb.co/vQH3H7G

After: https://ibb.co/Kr0T2f8
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PNG Resizing Transparency Issue

Post by cday »

xnview wrote: Thu Jun 17, 2021 4:04 pm could you post a file?
I think what Pierre would really like is an example file that doesn't work to examine and test, and ideally maybe also one that does...
kytrin
Posts: 5
Joined: Thu Jun 17, 2021 2:49 pm

Re: PNG Resizing Transparency Issue

Post by kytrin »

Okay... here is one that turns green in the background when I convert it: https://ibb.co/CWk8HcD

And here is one that converts fine: https://ibb.co/rcFPPTr

Neither image has been converted yet. Both are PNG. And both are from the same collection of images I'm working with.
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: PNG Resizing Transparency Issue

Post by XnTriq »

According to TweakPNG, …
  • 1344939-barbican-controls-down-ns-2x2.png is a 24-bit (truecolor) PNG + alpha channel = 32-bit (RGBA),
  • 1344899-barbican-1a-20x9.png is an 8-bit (indexed/palette-based) PNG with “cheap alpha” transparency.
Due to a limitation in XnView's library, an additional action (ImageChange color depth32 bits) is neccessary during batch conversion (prior to ImageResize) when you're dealing with “cheap alpha”. This extra step will ensure that transparency is preserved in all input files upon resizing.
Please make sure to use v0.98.2 or later.
kytrin
Posts: 5
Joined: Thu Jun 17, 2021 2:49 pm

Re: PNG Resizing Transparency Issue

Post by kytrin »

XnTriq wrote: Fri Jun 18, 2021 3:45 am According to TweakPNG, …
  • 1344939-barbican-controls-down-ns-2x2.png is a 24-bit (truecolor) PNG + alpha channel = 32-bit (RGBA),
  • 1344899-barbican-1a-20x9.png is an 8-bit (indexed/palette-based) PNG with “cheap alpha” transparency.
Due to a limitation in XnView's library, an additional action (ImageChange color depth32 bits) is neccessary during batch conversion (prior to ImageResize) when you're dealing with “cheap alpha”. This extra step will ensure that transparency is preserved in all input files upon resizing.
Please make sure to use v0.98.2 or later.
YES! That worked perfectly! Oh my god, thank you SO MUCH! I am definitely going to share this for others having the same problem! You are the literal best! : :D
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: PNG Resizing Transparency Issue

Post by XnTriq »

kytrin wrote: Fri Jun 18, 2021 12:05 pmYES! That worked perfectly! Oh my god, thank you SO MUCH! I am definitely going to share this for others having the same problem! You are the literal best! : :D
Welcome to the forum, kytrin (-:
User avatar
XnTriq
Moderator & Librarian
Posts: 6336
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: PNG Resizing Transparency Issue

Post by XnTriq »

… and thanks for spreading the gospel!
  • Converting Roll20 Assets for Dungeon Painter Studio
    “This guide outlines the process I use to most efficiently convert large numbers of Roll20 marketplace assets for use with Dungeon Painter Studio. In it, I show what programs I use and how I configure them in order to convert several hundred assets at a time, with little to no loss of quality.”
User avatar
NM64
Posts: 78
Joined: Sun Aug 05, 2007 7:17 pm

Re: PNG Resizing Transparency Issue

Post by NM64 »

I had to go dig out my ancient forum account after running into this issue when trying to convert several thousands of PNGs into WebP that are already organized into many subfolders. The issue however is that, despite the images using "cheap" transparency, setting the bit depth to 32bit before converting does not solve the issue - perhaps because these are images with more than 256 colors?

This is with the Linux 64bit version of XnView MP v0.98.4 and, for reference, Paint.NET on my Windows PC handles the transparency in the offending PNGs without issue... but Paint.NET lacks the batch-conversion process that I need.

I've attached an example of one of the offending PNGs (it's a game sprite that normally is overlayed onto the character's full-body sprite; speaking of which, the game itself handles the transparency fine if the PNGs are left as-is but I'm trying to convert to WebP to reduce file size).
Attachments
0.png
0.png (7.73 KiB) Viewed 2845 times
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PNG Resizing Transparency Issue

Post by cday »

You would naturally prefer an XnView MP solution :wink: but I think if you search online, there are possibly multiple plug-ins that add batch processing to Paint.Net...
User avatar
NM64
Posts: 78
Joined: Sun Aug 05, 2007 7:17 pm

Re: PNG Resizing Transparency Issue

Post by NM64 »

cday wrote: Fri Jul 09, 2021 7:17 am but I think if you search online, there are possibly multiple plug-ins that add batch processing to Paint.Net...
I found three plugins, two of which have been abandoned with dead download links and require the quite old v3.x of Paint.NET while the one remaining plugin that does support Paint.NET 4.x is only made available in source code - and while I'm a computer geek, coding is basically my one weak point (hardware is my specialty) so I wouldn't even know where to start with regards to compiling from source.

Also Paint.NET only works on Windows, and my "many-cores workstation PC" is running Linux which is where the preference to use XnView MP comes in. That said, it being Linux probably means that there's some fancy method using the terminal to batch-convert all of those PNGs to WebP using some CLI program - I should try asking one of my Linux guru buddies that similarly uses WebP for game sprites.


Amusingly in one of the threads for the old bulk plugins, they mentioned trying to use XnView's long-time arch-nemesis Irf*nView which I did actually humor myself and try - but it actually has the exact same problem that XnView has, and furthermore doesn't actually let you increase image bit depth, only decrease... and it's Windows only.
cday
XnThusiast
Posts: 3976
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: PNG Resizing Transparency Issue

Post by cday »

You would prefer an XnView MP solution, and as a Linux user myself now who only reluctantly boots into Windows 10 occasionally, I'm with you there! :D

I have used Paint.Net a few times, primarily because it is a freeware application that supports layers.

If Pierre can't immediately help you, I expect XnTrig will be able to when he logs on... :wink:
Post Reply