Log in

View Full Version : ImageSource problem with Targa files - unedited ones flipped, edited ones unflipped


wonkey_monkey
21st April 2021, 22:22
I used VirtualDub to export an image sequence of Targa (.tga) files. I then edited some of them in Photoshop.

When I use AviSynth and ImageSource to load the sequence, the edited ones are fine but the unedited are vertically flipped.

Anyone know what's up with that, and if there's a way around it?

Here are two of the images - one flips, one doesn't:

https://horman.net/flips.zip

poisondeathray
21st April 2021, 23:14
flipvertical() ?


I used colorbars().trim(0,-1) to test, and targa uncompressed export

vdub classic 1.10.4 x86 - NOT flipped
vdub classic 1.10.5 x64 - NOT flipped

vdub2 - flipped

So something with vdub2 branch targa exports

wonkey_monkey
21st April 2021, 23:38
The problem is that it's selective. The Targas I've edited have the opposite "flippage" to the ones that are unedited.

It suggests to me that there is some kind of flag in the Targa that Photoshop is honouring (and removing by "applying" the flip during editing), but ImageSource isn't. If you open the linked images above in Photoshop, both look normal. With ImageSource, one is flipped and one isn't.

poisondeathray
21st April 2021, 23:50
But photoshop "fixes" it when decoding, and it writes out a proper tga.

vdub2 tga ok in libavcodec based - ffmpeg, ffvideosource, lsmash (ie. not flipped) . Imagemagick in vapoursynth ok

Gimp doesn't even display the vdub2 tga . It opens, but it's "transparent" . vdub1 tga's are ok in gimp

djv_view doesn't open the vdub2 tga either (black screen), but vdub classic tga ok


Something up with vdub2 tga's if gimp can't open it properly - I don't think it's specifically limited to an avs/imagesource problem

patul
22nd April 2021, 04:58
There's similar event reported of general tga being flipped here (https://www.gamedev.net/forums/topic/195990-tga-image-format-flipped/). It said"If bits 4 and 5 in the Image Descriptor field (unpadded it would be offset 11h in the file) are zero then the image is "upside down".

Just curious, why tga? ImageWriter can output png.

wonkey_monkey
22nd April 2021, 09:51
Force of habit I spose. Although TGA output (from VirtualDub, not ImageWriter) is also 4x faster than PNG.

shekh
27th April 2021, 16:52
It seems I introduced some fixes at the same time as added alpha channel support. The header written by VD2 seem correct, don't know whats wrong with Gimp etc. I use tga 'all my life' and the upside-down flags are first thing to learn about it...

poisondeathray
27th April 2021, 18:23
ffmpeg seems to support it ok, but ffplay has issues similar to gimp

ffplay -i vdub2.tga => output is "black" screen, like gimp and djv

ffplay -i vdub.tga => output is ok


For mpv, vdub2.tga is "checkerboard" , indicating transparency

for mpv, vdub.tga is ok


The "flip" might be related to alpha channel introduction, or might be separate issue

poisondeathray
27th April 2021, 20:09
The transparency /alpha channel is not an issue; it was just a "bad" test input on my part

My original test input was colorbars(), but the alpha channel for RGB32 is with RGB 0,0,0 in the alpha plane

If you check in avisynth

ffvideosource()
showalpha()

vdub.tga shows 255,255,255
vdub2.tga shows 0,0,0

This is the expected output, since the input was actually a 0,0,0 alpha channel - so it should be "transparent"



It's unrelated to the "flip" issue w_m reported - in both RGB24 or RGB32 cases the vdub2 tga output is still flipped with imagesource; vdub tga output not flipped

Gimp is ok with RGB24 from vdub or vdub2 (not flipped, returns expected output)