conversion to RLE coded tga fails

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
tobyas

conversion to RLE coded tga fails

Post 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.
jpiquemal
Posts: 54
Joined: 2003-12-07T01:57:19-07:00

Re: conversion to RLE coded tga fails

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: conversion to RLE coded tga fails

Post by magick »

ImageMagick reads RLE-encoded Targa images but only writes uncompressed Targa.
tobyas

Re: conversion to RLE coded tga fails

Post 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...
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: conversion to RLE coded tga fails

Post 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!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: conversion to RLE coded tga fails

Post by dlemstra »

This has not been changed. We still only support uncompressed tga files. I will put it on my todo list :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: conversion to RLE coded tga fails

Post by jsanterre »

Many thanks for your quick answer!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: conversion to RLE coded tga fails

Post by dlemstra »

Support for RLE compressed TGA files has been added. The next version of ImageMagick (6.8.9-2) will include this.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: conversion to RLE coded tga fails

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: conversion to RLE coded tga fails

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: conversion to RLE coded tga fails

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: conversion to RLE coded tga fails

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: conversion to RLE coded tga fails

Post 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'.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: conversion to RLE coded tga fails

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: conversion to RLE coded tga fails

Post by magick »

ImageMagick 6.9.1-3 release will likely be before May 23rd.
Post Reply