Welcome! Log In Create A New Profile

Advanced

[WebDev 12 - PHP] Problem displaying 300dpi Image

Posted by JB 
I need to load a 300dpi image onto a page, add text to it and then allow it to donwload.

The problem is that when I download the image it has changed to 96dpi.

Any ideas how I can do it so that I keep my 300dpi?

Here's the code I use to save it at the moment:

dSaveImageJPEG(IMG_Seal_Big,sPath + "\BG_" + gsSealNo + ".jpg",100)
Fabrice Harari
Re: [WebDev 12 - PHP] Problem displaying 300dpi Image
May 07, 2009 10:50AM
Hi Jonathan...

I haven(t tested so I can't be sure, but it seems to me that your problem comes from the fact that you are displaying the image first THEN download it. here's why:
- when you display an image, it comes on the users screen, which is in this case working at 96 dpi
- when you start the download, as the image is ALREADY loaded by the browser for display, the cache system makes it come from the browser (96 dpi), not a second time from your server (300 dpi)

so if I'm right, a solution would be to save the image twice and use a different image name for the download...

BUT, dpi is not all, in fact it's just an information in the image header, and the total number of pixels of your image should not be affected by this: if your image is 800x600 originally, it should still be 800x600 at the end, even if it's tag as 96 dpi.

in fact, I found out in my image processing code that ignoring the dpi is generally a good idea, and working based on the image size help a lot instead

Best regards



Thanks for the tips Fabrice.

It is affecting the image as you say, the original size of the image is 500K but the downloaded size is only 40K with the same size.

I am now coding it using the ImageMagick command line to generate the image, which seams to work ok.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: