Converting raw greyscale BMP image

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?".
Locked
myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Converting raw greyscale BMP image

Post by myicq »

I have some raw BMPs I would like to have converted to BMPs with header.
I know the size of each data, and I know that each image contains 256 different colors

Example file is here: http://ge.tt/8DniNXb/v/0

Both original (.raw) and converted using paintShopPro. To convert I have selected "greyscale", "interleaved" and size 300 x 119

I have tried to use

Code: Select all

convert -size 300x119 -depth 8 rgb:qwerty.raw  qwertyout.bmp
but I only get "unexpected end of file".

Second part is how I specify a specific pallette for the output. Not a major issue though.

Hope someone can find out how to get from .raw to .bmp as per example in link.

Thanks.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting raw greyscale BMP image

Post by snibgo »

Your link is broken.
snibgo's IM pages: im.snibgo.com

myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Re: Converting raw greyscale BMP image

Post by myicq »

snibgo wrote:Your link is broken.
Just tried now from a different location. It's not broken.

If you wish the direct download link, this...

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting raw greyscale BMP image

Post by snibgo »

I think the "RGB:" format can only handle non-palette images. But if it's a palette image, there's no room in that file for the palette.

The "gray:" format can read the file, but I don't know if the result is correct.
snibgo's IM pages: im.snibgo.com

myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Re: Converting raw greyscale BMP image

Post by myicq »

The gray: image format did not make any difference..
The file being opened is exactly 35700 bytes, equal to 300 x 118.
It's a headerless BMP file in 8 bit format, one byte = 1 colour.
My attempts so far:

Code: Select all

c:\>convert -size 300x118 -depth 8 rgb:qwerty.raw q3.bmp
convert: Unexpected end-of-file (qwerty.raw).

c:\>convert -size 300x118 gray:qwerty.raw q3.bmp
convert: Unexpected end-of-file (qwerty.raw).

c:\>convert -size 300x118 -depth 1 gray:qwerty.raw q3.bmp
convert: Unexpected end-of-file (qwerty.raw).

c:\>convert -size 300x118 -depth 8 gray:qwerty.raw q3.bmp
convert: Unexpected end-of-file (qwerty.raw).

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting raw greyscale BMP image

Post by snibgo »

According to my arithmetic, 35700 = 300x119 (not 118).

Code: Select all

convert -size 300x119 -depth 8 gray:qwerty.raw q3.bmp
This works for me (IM v6.7.9 on Windows 7).
snibgo's IM pages: im.snibgo.com

myicq
Posts: 29
Joined: 2012-04-11T04:23:21-07:00
Authentication code: 8675308

Re: Converting raw greyscale BMP image

Post by myicq »

snibgo wrote:According to my arithmetic, 35700 = 300x119 (not 118).

Code: Select all

convert -size 300x119 -depth 8 gray:qwerty.raw q3.bmp
This works for me (IM v6.7.9 on Windows 7).
Snibgo - I never thanked you for the solution you gave here. This way works great.

Code: Select all

convert -size  {xsize}x{ysize} -depth 8  gray:{rawfile}   outputfile.bmp
So thumbs up for you!

Locked