Author Topic: Working with DPI with images...  (Read 8791 times)

0 Members and 1 Guest are viewing this topic.

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Working with DPI with images...
« on: December 05, 2009, 09:12:13 PM »
Is it possible to keep the DPI of images when you are resizing them with any of the graphic libraries?

I am posting this in regards to my [MOD] Multi Size Download of same image [ver 3.1]... but not really a question for just that mod so I thought I would post it here instead.

I noticed that when using the GD library to re-size from a larger file it comes across as 96dpi and not the original 250dpi the original file was in,
the only way I can think of fixing this would be to re-size my images on my computer using photoshop and uploading them to the server as the different size files to keep the DPI ratio consistent. Is this request beyond PHP ability or am I just not looking in the right spot?

Thanks for any direction/advice anyone can send my way...
Buddy Duke
www.budduke.com

Rembrandt

  • Guest
Re: Working with DPI with images...
« Reply #1 on: December 05, 2009, 09:49:51 PM »
Hi!

Quote
GD operates on the assumption that the output image will be rendered to a computer screen. By default, gd passes a resolution of 96 dpi to the freetype text rendering engine. This influences the "hinting" decisions made by the renderer. To specify a different resolution, set hdpi and vdpi accordingly (in dots per inch) and add gdFTEX_RESOLUTION to flags:

flags | gdFTEX_RESOLUTION;

 Perhaps you can help the source
otherwise ImageMagick

mfg Andi

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Working with DPI with images...
« Reply #2 on: December 05, 2009, 09:56:28 PM »
Perhaps I'm missing something, but isn't dpi = Dots Per Inch?
If so, then resizing an image will reduce the Dots Per Inch, therefore as smaller the image as less dpi
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: Working with DPI with images...
« Reply #3 on: December 06, 2009, 12:53:51 AM »
@Rembrandt,
Thanks for the info, I could not find anything in my own searching, will do some testing to see if I can make it work or not.

@V@no,
I work for a copier/printer dealership that works with full color high end equipment including wide-format printers so I have had to learn DPI real quick...
The easy way of looking at it is dpi is the amount of detail that is in one inch of a picture.
You can have an image that is 1024X768 at 150 dpi and another one 1024X768 at 300dpi,
same dimensions but more detail (dots) per inch of data. The reason people want the higher dpi is when you make the image bigger and do not want it to become fuzzy, the dpi is reduced.
If I double the size of the 1024X768 to 2048X1536, the dpi would be cut in half, one image would be 75DPI and the other is 150dpi. The reason this is important is when you go to print the image, the 75dpi would be very blurry, but the 150dpi may still look ok. Most images should be 250dpi or above to look photo quality depending on the printer doing the printing. So in turn, if I make the image 1/2 smaller 512X384 the dpi should double to 300 & 600.
you still keep all the detail the original image contained in a smaller picture.
I remember seeing an image out on the web somewhere that showed a picture of a town from a distance. It was taken at such a high DPI setting that you could keep zooming in on the picture to a man standing on a street corner smoking a cigarette that was not even visible in the original picture.

That is the problem I ran into with my mod. computer screens do not care about dpi, anything over 75-96 is a waste so for displaying thumbnails, etc... like 4images does, the routines worked just fine, but to actually resize and download the images for users that is a different story, especially if they want to print them out after they download them. so right now my mod would only work for sites that are doing computer wallpaper stuff and not actual printing but then again, If I was wanting to print something, why would a download a 640X480 version of an image when I can just download the original?

With the info that Rembrandt left, I will do some testing and see what I can come up with...

thanks for the fast responses and help!
Buddy Duke
www.budduke.com

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Working with DPI with images...
« Reply #4 on: December 06, 2009, 01:16:47 AM »
um...I don't work with printers, but what you said about two identical dimensions images but have different dpi doesn't make sense, because pixel is a pixel, you can not have more pixels in exact same size image and because of that only compression and perhaps some sharpening or other filters could alter the look of the image.
Now, printer (or software that transfer data to the printer) on other hand can change dimension of a picture on paper, and it would do exactly the same thing as does GD - changing the dimensions. And if prior printing the image was reduced in size, it would never be as good as the original one no matter how many dpi you set. As I understand the whole dpi thing, dpi is a factor of how accurate printer will print data to fit set dimensions, it's like compression factor when saving jpeg images...

So, if you want nice picture on paper, don't resize the original, or if you have to resize, compress it with minimum compression possible (or maximum quality).
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: Working with DPI with images...
« Reply #5 on: December 06, 2009, 02:23:45 AM »
I see were it gets confusing...

Pixels and inches are 2 different things.. (pixels are tv screen related and inches are print related)

If you have an image that is 1024X768 pixels at 150dpi that means that 150 of those pixels in the 1024 dimension are being used up for every inch of the image when it is being printed so this image would be printed at a size of 6.8 inches X 5.1 inches on paper, where as the same image 1024X768 pixels at 300dpi  using 300 pixels for every inch would print at a size of 3.5 inches X 2.5 inches on paper meaning the second picture is smaller on paper but with more detail (DPI) per inch of the picture. Some people use a loop (magnifying glass) to look at the dots on the paper to see just how much more detail there is on a 300dpi image to a 150dpi image.

printers do use some formulas for enlarging when you say fit page size, etc... we call it adding noise to the image to fill in the extra space to make the image fit. You can see it in photoshop if you take an image that is 1024X768 pixels at 300dpi and double its size without reducing the dpi, noise will be added to the image that makes it look blurry. you can add sharpening filters and stuff to clean it up but those pixels where not part of the original image so the original image has been modified at that point where as if you 1/2 the size of the pixel dimensions while doubling the dpi at the same time you still have the original image fully intact with all detail embedded inside it, so if later on you double the image back to the original size all the detail will still be there.

Do you ever wonder why the resolution on a monitor set at 1024X768 looks the same no matter the size of your monitor?
Like you said, a pixel is a pixel so 1024 pixels across a 17in monitor are the same number of pixels on a 24in monitor, just bigger pixels to fill in the extra 7 inches. so you can not really compare pixels/inches, you have to keep them separate, because your wallpaper that filled that 17in monitor looks the same on the 24in monitor but it is still 1024 pixels wide but it has changed in inches when you are viewing it. Very confusing...

That is why when a customer comes in with a low dpi image that they got off the web and want to print a poster size print of it, it does not work, only hi-res dpi images can be enlarged and printed on poster size paper and look photo quality.

So the way I always remember it is that the higher the dpi, the bigger your PRINTED image can be ENLARGED on a piece of paper without loosing any of the quality...
If you are only printing the image as is, the size it was scanned at then none of this really matters...

but, for my wallpaper folder that I have tons of pics in. I go in and change all the images to their same dimensions pixels wise but change the dpi to 96dpi no matter what I downloaded them at because I have no plans on printing any of them out and they look the same on my monitor and it saves a tons of diskspace by reducing the dpi.

Trust me, I have spent 21 years doing this stuff now and sometimes it still confuses me so I can understand what other people that do not deal with it all the time go through trying to understand it...

Hopefully this helps shed a little more light on the subject, It is kinda nice talking about something different for a change.

PS: your last statement regarding resizing is the best one to follow
Buddy Duke
www.budduke.com

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Working with DPI with images...
« Reply #6 on: December 06, 2009, 03:15:04 AM »
ok, I think I understand what you are saying, and also this article helped:
http://www.rideau-info.com/photos/changedpi.html

But as the article suggests, the image should not be resized to achieve best quality, it's almost suggests that DPI is an image parameter of some sort that stored inside the image...Either way, it seems the only possible (if possible) way changing dpi is use imagemagic...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)