atanunq / viu

Terminal image viewer with native support for iTerm and Kitty
MIT License
2.5k stars 54 forks source link

transparent images bug #99

Closed i30817 closed 2 years ago

i30817 commented 2 years ago

this image: thumb

when saved and used with viu -t thumb.png

displays a ugly red line in the border of the cover and the transparent part of the image. The image is done programmatically with python pillow code that glues 3 images, first in a side and the two others on top on the right side, and where the images are missing, a transparent area is glued instead.

My 'original transparent' images for the missing images sets a background rgba color of (255, 0,0,0) which is obviously the source of the 'red'.

Should i use (0,0,0,0) always, as a assumption that the alpha is always black for '-t' to work? Btw this has no problems in kitty, it's a xterm problem.

i30817 commented 2 years ago

Actually, i think the color i'm using doesn't matter (black was just less noticeable when i tested in either black background or white because it blended with the image).

So i think there is a off by one bug when applying -t - only for xterm/non sixel terminals.

Might also be a viuer bug.

i30817 commented 2 years ago

Here is a test:


#! /usr/bin/env python3

from PIL import Image
import subprocess, io

solid = Image.new('RGBA', (50,50), (0, 0, 0, 255))
t_red = Image.new('RGBA', (50,50), (255, 0, 0, 0))

combined = Image.new('RGBA', (100, 50))
combined.paste(solid, box=(0,0))
combined.paste(t_red, box=(solid.size[0],0))

#for comparasion
combined.show()
#for bug view
with io.BytesIO() as f:
    combined.save(f, format='png')
    subprocess.run(['viu', '-t', '-'], input=f.getbuffer())

btw, in xterm even without -t the red line appears so now i'm wondering if it's actually -t. As you can see from the first post or from the 'show()' call in the test, the image displays without the line in other viewers. Maybe instead of -t it's earlier in image decoding.

i30817 commented 2 years ago

Ah, i think this might be from the interpolation the library is doing when it needs to display on a non-sixel shell? Maybe it isn't taking into account transparent pixels shouldn't blend?

Should i open this bug in viuer instead?

i30817 commented 2 years ago

I'm closing this for a bug on viuer.