I am using php and fpdf to generate a pdf. How can I scale a 400 pixel high image to fit in a 300 point high space? The dimensions are just examples, the image and available space are dynamic.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to fit 400 pixels in 300 points, then your resizing factor would simply be
300 / 400= 0.75. You need to put each pixel in 0.75 of a point.But there is another story you should know: Each point is 1/72 of an inch. and how many pixels make 1 inch is a matter of choice.
All images have a property called DPI: dots per inch. It specifies how many pixels are there for each inch of the picture. So if you want to convert a 400px * 400px picture to a (say) 96 dpi image, your resizing factor will be
400 / ((72 / 96) * 400). 72 here is for converting inches to points.