Hi, new to the group.
I use the following code to resize images my users upload. They're
either blurry or they're jaggy.
Can someone recommend modifications or different code that will resize
images smoothly?
$o_file = $_GET['add'];
$image_info = getImageSize($o _file); // see EXIF for faster way
switch ($image_info['mime']) {
case 'image/gif':
if (imagetypes() & IMG_GIF) { // not the same as IMAGETYPE
$o_im = imageCreateFrom GIF($o_file);
} else {
$ermsg = 'GIF images are not supported<br />';
}
break;
case 'image/jpeg':
if (imagetypes() & IMG_JPG) {
$o_im = imageCreateFrom JPEG($o_file);
} else {
$ermsg = 'JPEG images are not supported<br />';
}
break;
case 'image/png':
if (imagetypes() & IMG_PNG) {
$o_im = imageCreateFrom PNG($o_file);
} else {
$ermsg = 'PNG images are not supported<br />';
}
break;
case 'image/wbmp':
if (imagetypes() & IMG_WBMP) {
$o_im = imageCreateFrom WBMP($o_file);
} else {
$ermsg = 'WBMP images are not supported<br />';
}
break;
default:
$ermsg = $image_info['mime'].' images are not supported<br
/>';
break;
}
if (!isset($ermsg) ) {
list($width, $height) = getimagesize($o _file);
if($width>200){
$t_wd = 200;
$t_ht = round(($t_wd / $width) * $height);
$t_im = imageCreateTrue Color($t_wd,$t_ ht);
imagecopyresamp led ($t_im,$o_im,0, 0,0,0,$t_wd,$t_ ht,$width,$heig ht);
imageJPEG($t_im );
imageDestroy($t _im);
}else{
imageJPEG($o_im );
imageDestroy($o _im);
}
}
?>
I use the following code to resize images my users upload. They're
either blurry or they're jaggy.
Can someone recommend modifications or different code that will resize
images smoothly?
$o_file = $_GET['add'];
$image_info = getImageSize($o _file); // see EXIF for faster way
switch ($image_info['mime']) {
case 'image/gif':
if (imagetypes() & IMG_GIF) { // not the same as IMAGETYPE
$o_im = imageCreateFrom GIF($o_file);
} else {
$ermsg = 'GIF images are not supported<br />';
}
break;
case 'image/jpeg':
if (imagetypes() & IMG_JPG) {
$o_im = imageCreateFrom JPEG($o_file);
} else {
$ermsg = 'JPEG images are not supported<br />';
}
break;
case 'image/png':
if (imagetypes() & IMG_PNG) {
$o_im = imageCreateFrom PNG($o_file);
} else {
$ermsg = 'PNG images are not supported<br />';
}
break;
case 'image/wbmp':
if (imagetypes() & IMG_WBMP) {
$o_im = imageCreateFrom WBMP($o_file);
} else {
$ermsg = 'WBMP images are not supported<br />';
}
break;
default:
$ermsg = $image_info['mime'].' images are not supported<br
/>';
break;
}
if (!isset($ermsg) ) {
list($width, $height) = getimagesize($o _file);
if($width>200){
$t_wd = 200;
$t_ht = round(($t_wd / $width) * $height);
$t_im = imageCreateTrue Color($t_wd,$t_ ht);
imagecopyresamp led ($t_im,$o_im,0, 0,0,0,$t_wd,$t_ ht,$width,$heig ht);
imageJPEG($t_im );
imageDestroy($t _im);
}else{
imageJPEG($o_im );
imageDestroy($o _im);
}
}
?>
Comment