Get exception "static planes value not equal to 1" when reading image raw data

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
ichaozai
Posts: 3
Joined: 2014-12-01T23:34:35-07:00
Authentication code: 6789

Get exception "static planes value not equal to 1" when reading image raw data

Post by ichaozai »

I use Magick++ for some image processing.
I read RGBA image raw data produced from another program and encode it to jpeg.
Most of time my codes work well, until I got this raw data that throw exception "static planes value not equal to 1".

Here is my short, self contained, example code. Sorry for the ugly hard coded numbers and strings, I just want to make it simple:

Code: Select all

int main(int argc, char **argv)
{
  int raw_buf_size = 4304768;
  char *raw_buf = (char *)malloc(raw_buf_size);
  FILE *f = fopen("magick_exception_1352x796_censored.data", "rb");
  if (f && raw_buf)
  {
    fread(raw_buf, 1, raw_buf_size, f);
    fclose(f);
  }

  Magick::Blob blob;
  blob.updateNoCopy(raw_buf, raw_buf_size, Magick::Blob::MallocAllocator);

  Magick::Image img;
  img.size("1352x796");
  img.magick("RGBA");
  img.depth(8);
  
  try {
    img.read(blob);  // <- throw exception here
  }
  catch (std::exception &e)
  {
    printf("%s\n", e.what());	
    return -1;
  }
  img.magick("JPEG");
  return 0;
}
Here is the raw data:
https://imgs-sandbox.intsig.net/icr/dem ... sored.data
Which is RGBA raw data, 1352 * 796 pixels. This raw data seems fine and is not corrupted, I can use GIMP 2 to load this raw data.

I want to know why Magick++ throw that exception and how can I fix it.
Thank you!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Get exception "static planes value not equal to 1" when reading image raw data

Post by snibgo »

What version of IM? What platform?
ichaozai wrote:exception "static planes value not equal to 1".
Please always quote the entire message, not just part of it.

The equivalent command is:

Code: Select all

convert -size 1352x796 -depth 8 RGBA:magick_exception_1352x796_censored.data c.png
This works with no problem.

If I omit "RGBA:"

Code: Select all

convert -size 1352x796 -depth 8 magick_exception_1352x796_censored.data c.png
... I get these error messages:

Code: Select all

convert.exe: length and filesize do not match `magick_exception_1352x796_censored.data' @ error/bmp.c/ReadBMPImage/813.
convert.exe: static planes value not equal to 1 `magick_exception_1352x796_censored.data' @ error/bmp.c/ReadBMPImage/825.
convert.exe: no images defined `c.png' @ error/convert.c/ConvertImageCommand/3230.
Note the error is from ReadBMPImage. IM is trying to read the image as a BMP format.
snibgo's IM pages: im.snibgo.com
Post Reply