Martin Kristiansen
Martin Kristiansen

Reputation: 10192

Loading an bmp using ImageMagick

I'l loading a bmp image using Image Magisk like this:

#include <Magick++.h> 
#include <iostream> 
using namespace std; 

int main(int argc,char **argv)
{ 
  Magick::InitializeMagick(*argv);

  Magick::Image image;
  try { 

    // Read a file into image object 
    image.read( argv[1] );

    cout << "image: " << argv[1] << endl; 
    cout << image.xResolution() << endl;
    cout << image.yResolution() << endl;

  } 
  catch( Magick::Exception &error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
      return 1; 
    } 
  return 0; 
}

The image I'm loading is this one:

e

Its a bmp and it can be loaded here the Actual bmp, the code compiles fine, but the resolution information is wrong, the program outputs:

image: ../sd_nineteen/HSF_0/F0000_14/HSF_0_F0000_14_C0000_14_100_e_65.bmp
0
0

Whats going on, is there a problem with imagemagick or with my image(I'm guessing there is a problem with my image).

Upvotes: 1

Views: 1116

Answers (1)

Tom
Tom

Reputation: 2036

Martin, it appears as though some image types (eg TIFF) support view resolutions, which are different than the actual image dimensions. The documentation on the topic is sparse, but looking at the source code it appears it may also have something to do with image density/DPI info.

Regardless of format, the actual image dimensions can be retrieved using the columns() and rows() methods of the Image class, rather than the (x/y)Resolution() methods.

Upvotes: 1

Related Questions