Page 1 of 2

conversion to RLE coded tga fails

Posted: 2008-10-25T01:42:14-07:00
by tobyas
Hi,

I've tried to convert images to tga and to runlength encoded tga.
First worked well, second not.

convert image.bmp image1.tga
convert image.bmp -compress RLE image2.tga

It appears to me that RLE compression for targa doesn't work at all.
Because image2.tga is identical to image1.tga.
Same result for

convert image.bmp -compress RunlengthEncoded image3.tga

Tested the behaviour with png and bmp as source images on ImageMagick 6.3.7 02/19/08 Q16 (linux)
and ImageMagick-6.4.4-10-Q8-windows-static.exe.

Re: conversion to RLE coded tga fails

Posted: 2008-10-26T00:23:09-07:00
by jpiquemal
[quote="tobyas"]Hi,

I've tried to convert images to tga and to runlength encoded tga.
First worked well, second not.

convert image.bmp image1.tga
convert image.bmp -compress RLE image2.tga

It appears to me that RLE compression for targa doesn't work at all.
Because image2.tga is identical to image1.tga.
Same result for

convert image.bmp -compress RunlengthEncoded image3.tga

Tested the behaviour with png and bmp as source images on ImageMagick 6.3.7 02/19/08 Q16 (linux)
and ImageMagick-6.4.4-10-Q8-windows-static.exe.[/quote]

Hello
It seems that there is no RLE coding for TGA in the IM code.

Re: conversion to RLE coded tga fails

Posted: 2008-10-26T13:12:18-07:00
by magick
ImageMagick reads RLE-encoded Targa images but only writes uncompressed Targa.

Re: conversion to RLE coded tga fails

Posted: 2008-10-27T12:34:53-07:00
by tobyas
magick wrote:ImageMagick reads RLE-encoded Targa images but only writes uncompressed Targa.
Hi jpiquemal and magick,

thanks for your reply. I know now, why it did not worked as expected.
Maybe I overlooked it, but I couldn't found this information in any kind of documentation.

If this is the case, I would suggest to add a note to the format list.
convert -list format | grep TGA

As I am a user 'only' in the meaning of IM, I will manually use GIMP for the rle conversion of Targa images...

Re: conversion to RLE coded tga fails

Posted: 2014-05-09T10:46:02-07:00
by jsanterre
Hi!

In 2008, magick wrote: "ImageMagick reads RLE-encoded Targa images but only writes uncompressed Targa".

Is it still the case today?

Many thanks!

Re: conversion to RLE coded tga fails

Posted: 2014-05-09T11:08:39-07:00
by dlemstra
This has not been changed. We still only support uncompressed tga files. I will put it on my todo list :)

Re: conversion to RLE coded tga fails

Posted: 2014-05-09T15:16:44-07:00
by jsanterre
Many thanks for your quick answer!

Re: conversion to RLE coded tga fails

Posted: 2014-05-12T12:06:48-07:00
by dlemstra
Support for RLE compressed TGA files has been added. The next version of ImageMagick (6.8.9-2) will include this.

Re: conversion to RLE coded tga fails

Posted: 2015-05-07T11:21:07-07:00
by jsanterre
That's awesome!

I did update to the latest IM (6.9.1) yesterday and tried this out. Writing RLE TGA files is working like a charm, I'm very happy. (I was relying on a RLE-Compressed TGA writer that I wrote myself, up to now...)

Now, I would need to detect when I read a TGA file if the TGA is compressed or not. Here's a portion of my code (I'm using Magick++ API)

Code: Select all

Magick::Image m_image;
(...)
m_image.read( filename );
m_compression = m_image.compressType();
m_quality = m_image.quality();


In the case of a TGA file, it seems that m_compression is always set to MagickCore::NoCompression, even if I read an RLE-compressed TGA (I'm pretty sure the file is effectively RLE-compressed because of its reduced size). Note that the above code is working well with other formats, for instance, the above code will detect a MagickCore::LZWCompression when reading a lzw-compressed tiff file. Also note that the above code was not able to detect a TGA RLE-compressed file written by my own writer.

It also seems to me that m_quality is always set to 0, regardless of how the file was written. Again, I feel I succeeded in writing files with different quality values because of the file size that is changing.

Thank you very much for your help!

Julie

Re: conversion to RLE coded tga fails

Posted: 2015-05-07T15:49:32-07:00
by dlemstra
Are you sure that your file really is RLE-compressed? Did you check the output of 'identify -verbose yourfile.tga'? Can you share one of the files? You can PM me if you don't want to share it publicly.

The tga coder does nothing with the quality so it will always report zero. So setting the quality when writing a tga image will not affect the output.

Re: conversion to RLE coded tga fails

Posted: 2015-05-08T08:19:16-07:00
by jsanterre
Hi there,

Thanks for your quick answer!

I will PM you two versions of a very simple image (so the RLE encoding will be very efficient) in just a few minutes. The file squares.tga is uncompressed with file size of 1407KB and squares_rle.tga is RLE-compressed with file size of 31KB.

I looked at both images in a binary viewer and in particular, at the third bytes of each file. I can see 02 for squares.tga and 0A for squares_rle.tga which is the Image type code corresponding to uncompressed/RLE-compressed TGA file (you already know that...).

Here are portions of the output I got from 'identify -verbose myfile.tga':

identify -verbose squares.tga
Image: squares.tga
Format: TGA (Truevision Targa image)
(...)
Iterations: 0
Compression: None
Orientation: Undefined
(...)
Artifacts:
filename: squares.tga
verbose: true
Tainted: False
Filesize: 1.44MB
(...)
Version: ImageMagick 6.9.1-2 Q16 x64 2015-04-14 http://www.imagemagick.org

identify -verbose squares_rle.tga
Image: squares_rle.tga
Format: TGA (Truevision Targa image)
(...)
Iterations: 0
Compression: None
Orientation: Undefined
(...)
Artifacts:
filename: squares_rle.tga
verbose: true
Tainted: False
Filesize: 31KB
(...)
Version: ImageMagick 6.9.1-2 Q16 x64 2015-04-14 http://www.imagemagick.org

And here's just a quick question about:
The tga coder does nothing with the quality so it will always report zero. So setting the quality when writing a tga image will not affect the output.
In the case of a PNG or a JPEG file written by Magick++ with say, quality = 50, can I retrieve that quality info when reading back that same image with the code I posted yesterday?

Again, thank you very very much for your help. It is highly appreciated...

Julie

Re: conversion to RLE coded tga fails

Posted: 2015-05-08T09:13:14-07:00
by dlemstra
I have e-mailed you because I did not get the files in your PM. When you read a .PNG file you won't be able to read the quality when you read the image again. And when you read a JPEG the quality is 'guessed', it will be really close to the value you used but it does not have to be the same.

Re: conversion to RLE coded tga fails

Posted: 2015-05-08T12:45:43-07:00
by dlemstra
I can confirm this is a bug in ImageMagick. In the next version of ImageMagick (6.9.1-3) the compression will be 'RLE' instead of 'None'.

Re: conversion to RLE coded tga fails

Posted: 2015-05-08T12:56:42-07:00
by jsanterre
Thank you for letting me know so quickly.

Do you have an idea of when (approximately, of course) this next version will be available?

Thanks!

Julie

Re: conversion to RLE coded tga fails

Posted: 2015-05-08T13:47:29-07:00
by magick
ImageMagick 6.9.1-3 release will likely be before May 23rd.