homepage Welcome to WebmasterWorld Guest from 54.224.179.98
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
Forum Library, Charter, Moderator: open

Site Graphics and Multimedia Design Forum

    
How best to resize digital real estate photos for web?
PHP's resizing image software often botches it
DeValle




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

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.

 

Cook




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

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?

Cheers,
Cook

mincklerstraat




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

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:
<?php
phpinfo();
?>

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.

DeValle




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

Cook:
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.

mincklerstraat:
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.

j_a_c_k




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

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 =======================
resampimagejpg($tgt_im_ht,$tgt_im_wd,$fpath,$fpath,0);

function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp) {
$g_imgcomp=100-$imgcomp;
$g_srcfile=$sourcefile;
$g_dstfile=$destfile;
$g_fw=$forcedwidth;
$g_fh=$forcedheight;
if(file_exists($g_srcfile)) {
$g_is=getimagesize($g_srcfile);
if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) {
$g_iw=$g_fw;
$g_ih=($g_fw/$g_is[0])*$g_is[1];
}else{
$g_ih=$g_fh;
$g_iw=($g_ih/$g_is[1])*$g_is[0];
}
$img_src=imagecreatefromjpeg($g_srcfile);
$img_dst=imagecreatetruecolor($g_iw,$g_ih);
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);
imagedestroy($img_dst);
return true;
}else{
return false;
}
}

Cook




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved