Be Kind To New Users
Be Kind To New Users

Reputation: 10063

Get Resolution and Dimensions of image using ImageMagick

I have the following code:

using (MagickImageCollection tiffPageCollection = new MagickImageCollection())
{
    tiffPageCollection.Read("some.tif");
    foreach (MagickImage tiffPage in tiffPageCollection)
    {
        int dpi = tiffPage.????;
        int height = tiffPage.????;
        int width = tiffPage.????;
    }
}

What do I place in ???? to get the respective property.

When I use visual studio to look at available properties and methods I see BaseHeight and BaseWidth, but when google those terms with "MagickImage" (the class) nothing turns up.

Where is the definitive reference documentation for Image Magick? The only doc I can find on magick.codeplex.com is sample documentation. That is helpful, but not what I need right now.

I can find other documentation, but it appears to be for the commandline image magic.

Upvotes: 1

Views: 4189

Answers (1)

zindarod
zindarod

Reputation: 6468

When it comes to ImageMagick APIs (or any library for that matter), your best bet is the source code itself. In your case the height, width and resolution are defined in MagickImage.cs.

Your code would be:

using (MagickImageCollection tiffPageCollection = new MagickImageCollection())
{
    tiffPageCollection.Read("some.tif");
    foreach (MagickImage tiffPage in tiffPageCollection)
    {
        Density d = tiffPage.Density;
        int height = tiffPage.Height;
        int width = tiffPage.Width;
    }
}

Upvotes: 3

Related Questions