GD default DPI

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm currently making a website that needs to edit images with adding text,
the problem is, the picture starts at 300 DPI (pixels/inch), but after GD
edits the image, it's set to 72 which i read to be the default value GD
always uses. is there a way to edit that default to a higher number, if not
are there other ways to edit images through php and still keeping the
original DPI.

Re: GD default DPI

Quoted text here. Click to load it

hi mc* !

here is an answer which I made here in May 2004

first : sorry for my (very) bad english, but I'm french (and nobody's

about picture :
picture is defined by X pixels x Y pixels (ie : 1200px x 856px).
on web (screen) this picture will fill a surface of 1200 pixels by 856
but for printing it (on paper) you must calculate :
if you print at 300dpi (good offset), dimensions of your picture on
paper will be 1200/300 by 856/300 thus 4 inches by 2.8 inches ;
if you print at 135dpi (offset), dimensions of your picture on paper
will be 1200/3135 by 856/135 thus 8.9 inches by 6.3 inches.

and if you want a 12 inches by 8.6 inches picture on paper its
resolution will be 100dpi.

thus, you can know the quality of your final print just by knowing the
dimensions (in pixels) of your picture.

about gd :
when I create a jpeg image with gd, I always have a 72dpi image.
I use the php getimagesize function and I calculate :
   round((getimagesize($my_picture)[0] * 0.85) / 100)
for width (cm) at 300dpi ;
   round((getimagesize($my_picture)[1] * 0.85) / 100)
for height (cm) at 300dpi.

'et voila !'

* here, in france, we have just had the first 'mad **goat**' !
what is a little worrying...
** this did not change !

E -00     yes ! france... near japan !
'   `)   /
 |\_ =="

Re: GD default DPI

Well, so u're saying i need to enlarge the image to later on resample it to
a smaller size so the DPI value is higher?
But i start with "uploaded" images, so if if i enlarge that image to later
resample won't the DPI value be lower again and/or won't the image have less
good pixelations?
Quoted text here. Click to load it

Re: GD default DPI

Quoted text here. Click to load it

no no no.

the image uploaded has its own dimensions : xxx pixels by xxx pixels.
that's all.

I understand that you use gd to add text to this image.

if the image is large enough to be printed correctly, just add your text
on it (do it by envisaging for the text an adapted size) then
dimensions of the new image, created by gd,  will not have changed.

but, the best you can do is to test yourself :

upload an image 250 px by 400 px (300dpi or 72dpi, we don't care) ;
do your job ;
download the new image ;
see what happens

E -00       comme on est very beaux dis !
'   `)   /
 |\_ =="

Re: GD default DPI

MC wrote:
Quoted text here. Click to load it

What about ImageMagick? There's a PHP module for it, called 'php_magick'.

Site Timeline