Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resizing an image in cm C#

I have an requirement that asks for an image with 10 X 6,88 cm. I know that I can't simple convert from cm to pixels, cause one pixel size depends on the user display resolution. I would like to know if there is a way to resize an image to have that size in cm. (I need to keep the image extension also. e.g.: can't convert it to a pdf or other extension)

like image 292
Victor Hugo Bueno Avatar asked Oct 23 '09 12:10

Victor Hugo Bueno


1 Answers

It really depends on in which resolution the user will print the image (sizes in cm makes little sense other than when printed). If the user wants to make a print in, say 200 dpi, then the image would need to be (10 / 2.54 * 200) by (6.88 / 2.54 * 200) pixels (the division with 2.54 is needed to convert between cm and inches). Which resolution that is needed is highly dependent on what kind of image it is, and the quality requirements of the user.

So just saying "I want to resize to X by Y cm" does not really make sense.

For a code sample on how to make the actual resize once you have figured out the needed size of the image, this SO answer should cover your needs.

like image 200
Fredrik Mörk Avatar answered Sep 21 '22 10:09

Fredrik Mörk