Here you can find the source of FindResolution(BufferedImage img, double print_width, double print_height)
public static int FindResolution(BufferedImage img, double print_width, double print_height)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; public class Main { public static int FindResolution(BufferedImage img, double print_width, double print_height) { int img_width = img.getWidth(); int img_height = img.getHeight(); System.out.println("Buffered Image Width: " + img_width + " Image Ht: " + img_height); int ppi1 = (int) ((double) img_width / (double) print_width); int ppi2 = (int) ((double) img_height / (double) print_height); int ppi = Math.min(ppi1, ppi2); System.out.println(" PPi1 " + ppi1 + " PPi2 " + ppi2 + " PPi " + ppi); return (ppi); }// w w w .ja v a 2 s . co m public static int FindResolution(int origImgWt, int origImgHt, double print_width, double print_height) { System.out.println("Original Image Width: " + origImgWt + " Ht: " + origImgHt); int ppi1 = (int) ((double) origImgWt / (double) print_width); int ppi2 = (int) ((double) origImgHt / (double) print_height); int ppi = Math.min(ppi1, ppi2); System.out.println(" PPi1 " + ppi1 + " PPi2 " + ppi2 + " PPi " + ppi); return (ppi); } }