Change of custom DPI value issue


#1

Dear Team,
I tried to convert image(tiff/ jpeg/ png) to PDF by setting custom dpi resolution value as 300dpi. The image had been converted into pdf but the conversion failed to set dpi resolution value as 300 dpi.
kindly provide a workaround solution.

Attached input file:
DPI Issue.zip (1.4 MB)
Code used:

Image image = (Image)Image.load(dataDir);
PdfOptions pdfOptions = new PdfOptions();
ResolutionSetting rs=new ResolutionSetting();
rs.setHorizontalResolution(300);
rs.setVerticalResolution(300);
pdfOptions.setResolutionSettings(rs);
dataDir = fileNameWithOutExt+".pdf";
image.save(dataDir,pdfOptions);


#2

@resh05,

I have observed your comments. Can you please visit this thread link. This will help you out in this issue. Please share feedback with us if there is still an issue.


#3

Hi @Adnan.Ahmad
I tried the above thread(DPI Issue) you posted but was unable to get the expected output.
Above thread only gives the changes in image width,height and dpi value is automatically applied but i need to set different dpi value for different images


#4

@resh05,

I like to inform that i have worked with your issue in detail. Can you please share more sample files along with generated result for testing purpose. Also please explain your issue in more details.


#5

@resh05,

Please visit this thread link. I have shared sample code that will help you to achieve your requirements.


#6

Dear @Adnan.Ahmad
Thanks for the code,it works fine…
My question is could we increase or decrease the dpi value for an image? If yes, then could you please provide me a workaround solution.
Attached sample:
12.jpg (17.7 KB)
Thanks


#7

@resh05,

I like to inform that we can change dpi value for PDF but for JPG image we have to investigate this on our end. A ticket with ID IMAGINGJAVA-1405 has been created in our issue tracking system. We will share good news with you soon.


#8

Dear @Adnan.Ahmad
Thank you :blush:


#9

@resh05,

You are very welcome.


#10

@resh05,

Can you please check following code and share feedback with us if this solution satisfy you.

RasterImage image = (RasterImage)Image.load(“12.jpg”);
try
{
Assert.assertEquals(image.getHorizontalResolution(), 96.0, 0.001, “Horizontal resolution must be equals 96 dpi”);
Assert.assertEquals(image.getVerticalResolution(), 96.0, 0.001,“Vertical resolution must be equals 96 dpi”);
image.setHorizontalResolution(300);
image.setVerticalResolution(300);
image.save(“output.jpg”);
}
finally
{
image.close();
}

image = (RasterImage)Image.load(“output.jpg”);
try
{
Assert.assertEquals(image.getHorizontalResolution(), 300.0, 0.001, “Horizontal resolution must be equals 300 dpi”);
Assert.assertEquals(image.getVerticalResolution(), 300.0, 0.001, “Vertical resolution must be equals 300 dpi”);
}
finally
{
image.close();
}


#11

Hi @Adnan.Ahmad
The code works fine.
Thank You…


#12

@resh05,

You are very welcome.