Raw GRAY/RGB images

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

Raw GRAY/RGB images

Post by chanoy » 2006-10-09T16:09:13-07:00


I'm trying to convert some raw (.gray, .rgb) images to ppm/pgm files. For gray images, I do something like

convert -size 1024x976 -depth 8 af1.gray af1.pgm

This works fine, however, I want to be able to have other options such as:

1.) specify file header size (meaning convert.exe will ignore the specified number of bytes at the beginning before converting the raw to pnm)
2.) For .rgb images, I would like to specific things like color order (RGB or BGR), Interleaved (RGB RGB... ) or Planar (RRR... GGG... BBB...), etc.

I'm not sure if ImageMagick has this type of options for converting raw to pnm. I was having trouble finding them.

Thanks for your time,


Post by chanoy » 2006-10-09T16:35:11-07:00

I found out how to add a header:

convert -depth 8 -size 1024x976+128 af1.gray af1.pgm

but i still trying to look for the other options I mentioned above.

User avatar
Site Admin
Posts: 10901
Joined: 2003-05-31T11:32:55-07:00

Post by magick » 2006-10-09T17:22:47-07:00

You can set interleaving with the -interlace option. You can grab pixel components in any order with the ImageMagick API but currently there is no method to read raw pixels in any order from the command line.

User avatar
Posts: 8875
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-10-10T18:41:17-07:00

There are othe runix commands that can handle file streams.

For example the UNIX 'dd' command can be used to remove 'X' bytes from the start of a character stream.

If the file is line orientated the comman 'tail' can be used to ignore say the first 2 lines
of a file.

IM Commands can read images from pipelines do you can just 'pipe' the output of one of these filters into IM.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages

Post Reply