[Solved] How do I create an 8-bit grayscale .TGA?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
shauno
Posts: 4
Joined: 2016-10-16T21:03:24-07:00
Authentication code: 1151

[Solved] How do I create an 8-bit grayscale .TGA?

Post by shauno »

I'm trying to create a texture to use in a game engine. This particular engine needs Targa 8Bpp Grayscale images without an alpha channel. Unfortunately, the program that I use (Paint.NET) will not save .TGAs lower than 24-bit, and it doesn't have an option for grayscale. I've tried to create one with ImageMagick using these parameters:

Code: Select all

convert spec.tga -type Grayscale -depth 8 spec2.tga
This spits out my spec2.tga, but when I try to import it into the game assets, it throws me this error:
Image

However, when I export and import the original texture, it works perfectly. I ran the identify command on both images to see what the difference was, but they seem to be exactly the same. (The original is ThisWorks.tga, mine is spec2.tga)
Image Image

I am using the latest version of ImageMagick (ImageMagick-7.0.3-4-Q16-x64-dll.exe) and I'm running on Windows 10. What am I doing wrong?
Last edited by shauno on 2016-10-17T00:12:51-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How do I create an 8-bit grayscale .TGA?

Post by snibgo »

I suppose there is some other difference between the files, and the error message you get is a generic "there is a problem" message.

There may be something in a TGA file that IM doesn't report because it isn't relevant to IM. "-strip" might solve that.

I suggest you look further in the "-verbose" outputs, and perhaps also exiftool.
snibgo's IM pages: im.snibgo.com
shauno
Posts: 4
Joined: 2016-10-16T21:03:24-07:00
Authentication code: 1151

Re: How do I create an 8-bit grayscale .TGA?

Post by shauno »

I don't think it's just a default "something happened" message because if I save the image as an 8-bit .png and then use IMDisplay to save it as a .tga, it gives me a different message saying "Error: TGA is not greyscale!"
Image

How do I get a better look at the identify outputs? For me it opens a command prompt, prints out all the info and immediately closes. It's only up for half a second and I had to take a screenshot just to read it. Is there any way I can make the window stay open or have it write to a text file?

I'll check out the -strip command and exiftool.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How do I create an 8-bit grayscale .TGA?

Post by snibgo »

shauno wrote:Is there any way I can make the window stay open or have it write to a text file?
Yes, you can write it to a file. I don't know how you are running commands such that the window immediately closes. I suggest you open a command window, and type commands in it. Then the window will stay open until you tyoe "exit".

Almost all IM tools are designed to be run from the command prompt, in a command prompt window.
snibgo's IM pages: im.snibgo.com
shauno
Posts: 4
Joined: 2016-10-16T21:03:24-07:00
Authentication code: 1151

Re: How do I create an 8-bit grayscale .TGA?

Post by shauno »

This is what happens when I run IM with identify: https://youtu.be/tiDXyJkiNBY

How do I have it write to a file? I tried -debug -log but it didn't do anything. Or maybe it did write to a log and I just can't find it? Help me out here.
shauno
Posts: 4
Joined: 2016-10-16T21:03:24-07:00
Authentication code: 1151

Re: How do I create an 8-bit grayscale .TGA?

Post by shauno »

Derp. It was doing that because I was using the start command which opens the command prompt in a new window. :?

So I found out the original image has only three RGB values while mine has a fourth one.
Image Image

I suppose that's for alpha? I supposed that's what was causing the problem, so instead of Grayscale I used GrayscaleMatte to remove the alpha channel and it worked! Wonderful! Thanks for your help.
Post Reply