Help with converting a really weird image format to PNG

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
DodoDude700
Posts: 2
Joined: 2016-02-15T14:38:45-07:00
Authentication code: 1151

Help with converting a really weird image format to PNG

Post by DodoDude700 »

Hello!
I am looking to use ImageMagick to convert a Format 64 image extracted from iPod Nano firmware to a PNG or something more normal. I know the format of this image, at least to the extent offered by the below explanation:
One int32 for palette size,
then 4 times that amount of ARGB8888 bytes,
then 8 BPP image data
I also know the dimensions of the image (they should be 26x13), though I do not know what it should look like if converted properly. The image can be downloaded here: https://dl.dropboxusercontent.com/u/911 ... 4Image.bin
psImg
Posts: 2
Joined: 2016-02-16T10:53:09-07:00
Authentication code: 1151

Re: Help with converting a really weird image format to PNG

Post by psImg »

Followed the instructions - First int32 is 87, then (87*4) bytes defining the palette, then the remaining (26*13) bytes are each pixel's value (between 0 and 86, i.e. referencing a palette entry)

but couldn't make it look like much of a coherent image:

http://i.imgur.com/5S764yV.png
DodoDude700
Posts: 2
Joined: 2016-02-15T14:38:45-07:00
Authentication code: 1151

Re: Help with converting a really weird image format to PNG

Post by DodoDude700 »

OK, cool, but what command was that? I need to do this programatically.
psImg
Posts: 2
Joined: 2016-02-16T10:53:09-07:00
Authentication code: 1151

Re: Help with converting a really weird image format to PNG

Post by psImg »

I don't think imagemagick is the right tool for this job; it's not a format that it knows about already.

I used matlab because I'm a hack

Code: Select all

fid = fopen('Format64Image.bin');
dim = [26 13];

first   = fread(fid,1,'*int32','l');
palette = fread(fid,[first 4],'*uint8','l');
imgdata = fread(fid,dim,'*uint8','l');

fclose(fid)

img=reshape(palette(imgdata+1,:),[dim 4]);
imwrite(img(:,:,1:3),'test.png','png','Alpha',img(:,:,4));
but will be similarly short in any language + an image library
Post Reply