Get resolution

Hi Team,

Is this possible to get resolution of embedded image from the pdf document.

I am use this imagePlacement.getResolution().getY(); method to get the resolution values.it gave 1px lesser value as compare to other software like adobe photoshop cc.

please kindly help me to get resolution of image from pdf using Aspose.pdf in java

sample1: sample3.zip (577.6 KB)

Thanks & regards,
Priyanga G

@priyanga

Thank you for contacting support.

We would like to share with you that getY method returns an integer value, so 219 is displayed by Aspose.PDF for Java API. When we check the resolution of it in Adobe Acrobat, vertical resolution is displayed as 219.83 which is returned as 219 as an integer value. We have attached a screenshot for your kind reference. AcrobatResolution.JPG

We hope this will clarify any ambiguity. Please feel free to contact us if you need any further assistance.

Hi @Farhan.Raza,

Thanks for your feedback.

Is this possible to get 219.83 as rounded to 220 using aspose.pdf java. Kindly Please provide quick solution for this problem .

As soon as possible.

Thanks & regards,
priyanga G

@priyanga

We are afraid that a float or rounded-off value may not be obtained at the moment. However, an investigation ticket with ID PDFJAVA-37769 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Hi @Farhan.Raza,

PDFJAVA-37769 ---- Status : Resolved

please kindly provide the solution for this issue .

Thanks & regards,
priyanga G

@priyanga

Thank you for getting back to us.

We would like to share with you that, while investigating this issue further, we tested the resolution by downloading it via Adobe Acrobat DC and with few graphic editors including Adobe Photoshop CC 2018/ Gimp / Krita 2.8.1; and concluded that it is not a bug with the API. However, we have reopened it to take care of your concerns. Further investigations will be carried out and we will let you know about further findings. Please be patient and spare us little time.

@priyanga

Thank you for being patient.

We would like to update you that the value was rounded off to 219 as the Adobe Acrobat do the same by saving the image so this could not be changed, but there is a way to get most accurate float value by below code:

...
for (Object imagePlacement : abs.getImagePlacements())
{     
    ImagePlacement placement = (ImagePlacement) imagePlacement;
    System.out.println("image horizontal resolution:" + placement.getImage().getWidth() * 72 /  placement.getRectangle().toRectangleF().getWidth());
    System.out.println("image vertical resolution:" + placement.getImage().getHeight() * 72 /  placement.getRectangle().toRectangleF().getHeight());
}
...

Output for two images:

image horizontal resolution:219.87086
image vertical resolution:219.82544

image horizontal resolution:219.9648
image vertical resolution:219.82544

These results are same as in Adobe Preflight PDF Analysis. We hope this will be helpful. Please feel free to contact us if you need any further assistance.

@priyanga

Please use updated code snippet for your kind reference.

for (Object imagePlacement : abs.getImagePlacements()) {
ImagePlacement placement = (ImagePlacement) imagePlacement;
System.out.println("image horizontal resolution:" + placement.getImage().getWidth() * 72 / placement.getRectangle().getWidth());
System.out.println("image vertical resolution:" + placement.getImage().getHeight() * 72 / placement.getRectangle().getHeight());

}

Output for two images:

image horizontal resolution:219.87086948609732
image vertical resolution:219.82544641389063
image horizontal resolution:219.96479303109257
image vertical resolution:219.82544641389063

Please feel free to contact us if you need any further assistance.