Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

How best to resize digital real estate photos for web?

PHP's resizing image software often botches it



12:45 am on Oct 14, 2004 (gmt 0)

10+ Year Member

I have a real estate site whereby the broker may upload his own listings. Trouble is, when the broker goes through our PHP control panel application for uploading home photos, the end result on the web often looks like crap. Roof angles and any other angle gets that jagged tiled look. Some photos come out OK, some look horrible. I can't find a common denominator for the problem.

Our web format is 300 pixels wide. That's what we want the final uploaded photos to be.

Is there a process that we can use? Keep in mind that it's artistically and technologically clueless people who upload these images-- not us-- so it has to be idiot proof. And of course the original digital output from a given broker's camera may be anywhere from 640 X 480 on up. We never know.

This is a PHP/MySQL Linux site. I would appreciate anybody's experience or advice on this.


7:46 am on Oct 14, 2004 (gmt 0)

10+ Year Member

Hi DeValle,

How do you resize the photos now? Do the brokers do it for you prior to uploading? Or do you do it on your end upon uploading?



9:36 am on Oct 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Sounds like it's the PHP interface that's resizing the photos, and sometimes doing a botched job.

There are a number of means for resizing photos available to PHP, in the form of image processing libraries. These are GD1, GD2, imagemagick, and netbpm.

GD1 produces the least visually appealing results. I'd guess your software is using GD1 functions. Make a php info file - below:

See if under the heading 'gd' the 'gd version' is 2 or higher. If so, you can use gd2 functions.

Try replacing every occurrence of 'imagecreate(' with 'imagecreatetruecolor(' and you'll then be using the GD2 pallette, which is a lot richer.

Another possible culprit is the saving of the image with imagejpeg(). If there's a number at the end of the arguments of this function, that number determines the quality of the jpeg (lower number = lower quality, smaller size in K (though sometimes insignificantly smaller)). Hike this up to about 75 if it's in there - see [be2.php.net...] .

Feel free to sticky me on this matter or send code.


11:13 am on Oct 14, 2004 (gmt 0)

10+ Year Member

We're using one of the PHP image processing libraries. The broker uploads his own photos online from within our control panel. See below because this is rapidly getting beyond my pay grade.

Thanks for the info on GD2 and the imagejpeg() function. That looks promising. Since I'm about 80% designer and 20% developer and am only just now learning PHP/MySQL, I'm asking our developer partner to jump in on this string straight away.

Thank you both for your replies.


5:19 am on Oct 17, 2004 (gmt 0)

10+ Year Member

I would be the developer partner in question.

We would seem to have the suggested points covered.
We are using GD 2.0.12
The function that I am using seems to fulfill all the suggested solutions and yet we get poor results. I am currently asking for zero compression on the jpg.

Any additional thoughts on this would be greatly appreciated.

================== code =======================

function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp) {
if(file_exists($g_srcfile)) {
if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) {
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
return true;
return false;


10:53 am on Oct 17, 2004 (gmt 0)

10+ Year Member

I read somewhere that imagejpeg's quality parameter ranges from 0 to... 95, not 100. Try changing that and see what happens.

Featured Threads

Hot Threads This Week

Hot Threads This Month