tags:

views:

355

answers:

3

I want to resize a image with DPI 300 or greater.. I want it's DPI to remain intact... I have used GD library function to resize image cropped but it brings down DPI to 90! please give a solution as my requirement involves no downsizing of DPI

A: 

DPI means dots per inch. If you resize the image, the amount of inches stays the same (you show the same image), but the amount of dots goes down (less pixels).

So if you lower the size of the image, you always lower the DPI.

Thirler
+2  A: 
  1. Take image, say it's 1000 x 1000 Pixels large
  2. Crop / resize image to a portio, say, 100 x 100 Pixels large
  3. Enlarge 100 x 100 portion to 1000 x 1000 Pixels - use imagecopyresampled() for best results - manual
  4. Done!

This comes at the price of lower quality, obviously.

It's going to be impossible to enlarge an image with no quality loss. You won't be able to retain the original image quality when enlarging because the pixel information simply isn't there. There are resizing algorithms that employ antialiasing and other techniques (like resampling in imagecopyresampled() to help the quality, but it will never be perfect.

If you want to display a large image smaller without losing any image data, you would put it into a img tag and then scale it down using the css width property. Note: This is not going to give you any better quality than resizing the image. In addition you are transferring more data than necessary, and in some browsers the result of the resizing may look bad due to the use of low-quality (but fast) algorithms - so the image may end up looking worse.

Pekka
thanks for clarifying my doubts and giving a way to tweak the presentation using img tag
ashofphoenix
The link to the php manual is missing a 'd' at the end of the function name
Max
Cheers @Max, corrected.
Pekka
A: 

So if you lower the size of the image, you always lower the DPI.

thats not true the DPI is just a "conversion" used when you print something, it says nothing about the quality of the picture onscreen. if you resize a picture (pixelsize that is) the printed versions shrinks the same way if you don't touch the DPI. you could keep the printed size the same, but that would mean lowering the DPI

1200*1200px image with 300dpi is 4"*4" printed

600*600px image with 300dpi is 2"*2"

600*600px image with 150dpi is 4"*4"

if you use imagecopyresampled() the DPI should stay the same in the image

nr404