Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-06 Thread Bob Friesenhahn

On Thu, 4 Aug 2022, Bob Friesenhahn wrote:

Testing with ImageMagick 6.9.12-38 on an Illumos system shows the image the 
other way around with the bright pink cone laying on what might be a gray 
floor.  Due to the nature of the image, it is difficult to tell what the 
right way up is.


It appears that ImageMagick 6.9.10-23 and 6.9.12-38 do not display the same 
output!


Thankfully this issue brought my attention back to TGA format.  I 
found that an unnecessary security check was blocking reading some 
files entirely.  I also noticed that the code could be optimized a 
bit.


However, I believe that this bug report is incorrect.

What has actually happened is that ImageMagick changed what it 
returns and more recent ImageMagick also changed what it does when it 
displays an image.


GraphicsMagick always returns an image in the common normal form 
(TopLeft).  ImageMagick changed so that it returns an image in the 
same form as the file, but it sets an orientation option so that the 
user needs to use -auto-orient to see a correct image.


In the older version of ImageMagick, the 'display' program does not 
appear to automatically adjust the orientation where as the newer 
version does.


This morning I committed the TGA improvements and created a new 
development snapshot release.


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt



Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread Bob Friesenhahn
Testing with ImageMagick 6.9.12-38 on an Illumos system shows the 
image the other way around with the bright pink cone laying on what 
might be a gray floor.  Due to the nature of the image, it is 
difficult to tell what the right way up is.


It appears that ImageMagick 6.9.10-23 and 6.9.12-38 do not display the 
same output!


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt



Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread Bob Friesenhahn

On Thu, 4 Aug 2022, Bob Friesenhahn wrote:


On Thu, 4 Aug 2022, László Böszörményi (GCS) wrote:


I see that a bit of code in 'tga.c' dealing with image orientation was
commented out because the compiler warned that it produced an invalid
result.  That was unfortunately not attended to.

Did you fix it with changeset 16721 [1]? I don't have time to compile
and check it ATM, but might package it tomorrow if it's a proper fix.


No it is not fixed yet.  I fixed a different bug, which caused some sample 
files to not be read at all.


While it would not surprise me all if there is an orientation bug in 
GraphicsMagick, for the provided case, the image shown by ImageMagick 
6.9.10-23 and GraphicsMagick is exactly the same.


The orientation which likely has issues is the exceedingly rare case 
where the row pixels may need to be written in reverse.


Can this issue be reproduced independently?

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt

Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread Bob Friesenhahn

On Thu, 4 Aug 2022, László Böszörményi (GCS) wrote:


I see that a bit of code in 'tga.c' dealing with image orientation was
commented out because the compiler warned that it produced an invalid
result.  That was unfortunately not attended to.

Did you fix it with changeset 16721 [1]? I don't have time to compile
and check it ATM, but might package it tomorrow if it's a proper fix.


No it is not fixed yet.  I fixed a different bug, which caused some 
sample files to not be read at all.


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt

Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread GCS
Hi Bob,

On Thu, Aug 4, 2022 at 9:39 PM Bob Friesenhahn
 wrote:
> On Thu, 4 Aug 2022, Ivan Shmakov wrote:
> >   While graphicsmagick claims to support ‘Truevision Targa’
> >   format, its implementation is apparently slightly defective
> >   in that the images are read and written with their vertical
> >   axis reversed.  Consider, for instance, SHAPES.TGA from [1]:
> >   it’s shown with the gray (#9c9c9c) ‘floor’ at the bottom of
> >   the image by both LDPCXTGA.EXE and ImageMagick’s display(1),
> >   yet $ gm display SHAPES.TGA shows the floor at the /top/ of
> >   the image instead.
>
> I see that a bit of code in 'tga.c' dealing with image orientation was
> commented out because the compiler warned that it produced an invalid
> result.  That was unfortunately not attended to.
 Did you fix it with changeset 16721 [1]? I don't have time to compile
and check it ATM, but might package it tomorrow if it's a proper fix.

Thanks,
Laszlo/GCS
[1] http://hg.graphicsmagick.org/hg/GraphicsMagick/rev/2504f4ed1a52



Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread Bob Friesenhahn

On Thu, 4 Aug 2022, Ivan Shmakov wrote:


While graphicsmagick claims to support ‘Truevision Targa’
format, its implementation is apparently slightly defective
in that the images are read and written with their vertical
axis reversed.  Consider, for instance, SHAPES.TGA from [1]:
it’s shown with the gray (#9c9c9c) ‘floor’ at the bottom of
the image by both LDPCXTGA.EXE and ImageMagick’s display(1),
yet $ gm display SHAPES.TGA shows the floor at the /top/ of
the image instead.


I see that a bit of code in 'tga.c' dealing with image orientation was 
commented out because the compiler warned that it produced an invalid 
result.  That was unfortunately not attended to.


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt

Bug#1016653: gm(1): targa (.tga) files are read and written upside-down

2022-08-04 Thread Ivan Shmakov
Package: graphicsmagick
Version: 1.4+really1.3.38-1
Severity: minor
Control: found -1 1.4+really1.3.36+hg16481-2
Control: found -1 1.4+really1.3.35-1~deb10u2

[Please do not Cc: me, for I’m “on the list,” so to say, and
I try to reserve my inbox for private communication only.
I’d have set up Mail-Followup-To:, but there doesn’t seem to
be a way to make it point to the report being filed.]

While graphicsmagick claims to support ‘Truevision Targa’
format, its implementation is apparently slightly defective
in that the images are read and written with their vertical
axis reversed.  Consider, for instance, SHAPES.TGA from [1]:
it’s shown with the gray (#9c9c9c) ‘floor’ at the bottom of
the image by both LDPCXTGA.EXE and ImageMagick’s display(1),
yet $ gm display SHAPES.TGA shows the floor at the /top/ of
the image instead.

[1] http://archive.org/download/simtelnet_bu_mirror_2013_04
/simtelnet.bu.mirror.2013.04.zip/simtelnet%2Fmsdos%2Fgraphics
%2Fldpcxtga.zip (URI split for readability.)

The same applies to images produced with $ gm convert.

The obvious workaround is to use -flip, like:

$ gm display -flip SHAPES.TGA 
$ gm convert input.file -flip output.tga 

-- 
FSF associate member #7257  http://am-1.org/~ivan/