Page 1 of 1

[SOLVED] Problem converting from rgba to jpg on iOS and OSX

Posted: 2014-11-04T02:57:00-07:00
by che1404
Hi,
I have an algorithm that takes snapshots from an OpenGL context. For each snapshot, I create an .rgba raw file, just reading the pixels from the buffer.
Then for each rgba file, I use ConvertImageCommand() to convert to jpeg. This commands works fine for the majority of the files, but it always fails with the 8th file I try to convert. Then it keeps doing it fine.

The specific parameters I'm using are:

Code: Select all

convert -size 1512x1532 -depth 8 soruce.rgba dest.jpg
The error I get in the exception is:

Code: Select all

NoImagesDefined `/var/mobile/Containers/Data/Application/4C9DACEC-EF5C-43D3-B122-1B853C19DB84/Library/Caches/TextureCache/converted0.jpg' @ error/convert.c/ConvertImageCommand/3150
I'm using ImageMagick for iOS, version 6.8.8-9.

If I download the rgba files from the iPad to the Mac, and use the convert command with the verbose option, I can see that ImageMagick is treating the input image as PCX, and not as RGBA, like the rest of the files.

Code: Select all

MacBook-Pro-de-Roberto:TextureCache ro$ convert -verbose -size 1512x1532 -depth 8 raw0.rgba converted0.jpg 
raw0.rgba PCX 1x1 1x1+0+0 16-bit sRGB 9.266MB 0.000u 0:00.009
raw0.rgba=>converted0.jpg PCX 1x1 1x1+0+0 8-bit sRGB 288B 0.010u 0:00.000
In spite of telling the size, ImageMagick is using 1x1. Also, PCX format, instead of RGBA.

With the next file, the conversion is fine:

Code: Select all

MacBook-Pro-de-Roberto:TextureCache ro$ convert -verbose -size 1512x1532 -depth 8 raw1.rgba converted1.jpg 
raw1.rgba RGBA 1512x1532 1512x1532+0+0 8-bit TrueColor sRGB 9.266MB 0.020u 0:00.039
raw1.rgba=>converted1.jpg RGBA 1512x1532 1512x1532+0+0 8-bit sRGB 408KB 0.120u 0:00.119
The ImageMagick version on my Mac is also 6.8.8-9.

Does any of this tell you something?

EDIT: The raw file is just fine. I can open it with Photoshop, specifying the size:

Image

SOLVED: Apparently I had to prepend "RGBA:" to the input file. Now it works.

Thanks,
Robert.

Re: [SOLVED] Problem converting from rgba to jpg on iOS and

Posted: 2014-11-04T08:02:23-07:00
by snibgo

Code: Select all

convert -size 1512x1532 -depth 8 soruce.rgba dest.jpg
"-size 1512x1532" is a setting for creating new images with "xc:" or "canvas:". In your command, it is ignored.

"-depth 8" forces the output to be 8 bits. Jpeg files are always 8 bits. So this is also ignored.

So that command could be simplified:

Code: Select all

convert soruce.rgba dest.jpg