Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

png alpha channel loss #144

Closed
Kaens opened this issue Mar 25, 2021 · 3 comments
Closed

png alpha channel loss #144

Kaens opened this issue Mar 25, 2021 · 3 comments

Comments

@Kaens
Copy link

Kaens commented Mar 25, 2021

Hi,
I found a bug where the alpha channel is lost.
Using waifu2x-ncnn-vulkan-20210210-windows on an RTX 2070.
The command-line switch is just "-n -1" or "-n 0".

Before: 225986290

After: 225986290@2x

@ghost
Copy link

ghost commented Apr 2, 2021

The bit value of the image is strange. (It is marked as 8bit in Windows properties. It must be marked in 32bit.)
Use'-pix_fmt rgba' in ffmpeg or save it through a separate image editing program.

@CounterContradiction
Copy link

CounterContradiction commented Jul 2, 2021

@Kafu-Yukimura is right.

I have a similar image where it showed that it is 8bit if viewed through Windows Properties(Right Click-> Properties), and it also losses its transparency when using waifu2x-vulkan.
image

I saved your image as bear.png and run it through ffmpeg with the suggested command:
.\ffmpeg.exe -i .\bear.png -pix_fmt rgba bear_ff.png
And bear_ff.png ran without losing its transparency (-s 2 -n 2):
bear_ff2x

An altenative I found is with python and the Pillow library:

from PIL import Image
img = Image.open("bear.png")

#Checks if img is 8bit
if img.mode == "L" or img.mode == "P":
    #Converts to 32 bit and overwrites the original image. 
    #Use a different filename from the original if you want to preserve the original image.
    img.convert("RGBA").save("bear.png")  

@nihui
Copy link
Owner

nihui commented Apr 19, 2022

fixed in 7ab564a

@nihui nihui closed this as completed Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants