We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get image dimensions


I’m trying to get image size and dimension of the attached pdfs. When an image is 150% or higher form the original size I would like to reject the file.

I found an example in your docs “Getting Image Information without Extracting the Images”:

But unfortunately I never reach the part where ScaledWidth and OriginalWidth is calculated.

I’ve adjusted the example so it will iterate through all pages and all contents:
Code snippet:

//Iterate through all the pages
foreach (Page page in doc.Pages)

// Get all the operators on first page of document
foreach (Operator op in page.Contents)


I also tried the example with the ImagePlacementAbsorber, but that doesnt contain any images at all.

Could you help me to get dimensions and scaling of images in this example pdf?

Could you please update this when do you expect to be able to look into this... ?

Thank you in advance

Hi Sander,

Thanks for using our products and sorry for the delayed response.

I have tested the scenario using Aspose.Pdf for .NET 8.1.0 using following code snippet and as per my observations, the image dimensions and related information is properly being retrieved. Can you please share which version of product you are using. We are sorry for this inconvenience.


// Load the source PDF document<o:p></o:p>

Aspose.Pdf.Document doc = new Aspose.Pdf.Document("c:\\pdftest\\Hybride2.pdf");

ImagePlacementAbsorber abs = new ImagePlacementAbsorber();

// Load the contents of first page


foreach (ImagePlacement imagePlacement in abs.ImagePlacements)


// Get image properties

Console.Out.WriteLine("image width:" + imagePlacement.Rectangle.Width);

Console.Out.WriteLine("image height:" + imagePlacement.Rectangle.Height);

Console.Out.WriteLine("image LLX:" + imagePlacement.Rectangle.LLX);

Console.Out.WriteLine("image LLY:" + imagePlacement.Rectangle.LLY);

Console.Out.WriteLine("image horizontal resolution:" + imagePlacement.Resolution.X);

Console.Out.WriteLine("image vertical resolution:" + imagePlacement.Resolution.Y);

Console.Out.WriteLine("\n ----- ");

// Retrieve image with visible dimensions

Bitmap scaledImage;

using (MemoryStream imageStream = new MemoryStream())


// Retrieve image from resources

imagePlacement.Image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);

Bitmap resourceImage = (Bitmap)Bitmap.FromStream(imageStream);

// Create bitmap with actual dimensions

scaledImage = new Bitmap(resourceImage, (int)imagePlacement.Rectangle.Width, (int)imagePlacement.Rectangle.Height);



Hi Nayyer,

Thank you for your reply. I've used Aspose Pdf for .NET 8.0.0 and retested with 8.1.0 but the results were the same. However after applying a (30day demo) license file I could use the ImagePlacementAbsorber which returned an ImagePlacementCollection with all the properties.

Thank you for your example, now I could easily use image resolution and scaling to decide if image has a minimum quality. Problem solved!

Kind Regards

Hi Sander,

I am glad to hear that your problem is resolved while using the license file. Furthermore I would like to share that recently we have published a new version of Aspose.Pdf for .NET 8.2.0. You may consider upgrading to the latest release.

In the event of any further query, please feel free to contact.