imagecopyresampled will shrink an image smoothly, but if you try to use it to enlarge an image, the result will be blocky, like in imagecopyresized. The following function will enlarge an image more smoothly using bilinear resampling.

function imagecopyenlarged ( $dst_im , $src_im , $dstX , $dstY , $srcX , $srcY , $dstW , $dstH , $srcW , $srcH )
{
for ( $y = $dstY ; $y < $dstH ; $y ++ )
{
$tempy = ( $y - $dstY ) * $srcH / $dstH + $srcY;
$tempyd = $tempy - floor ( $tempy );
$tempyu = 1 - $tempyd;
$tempy = floor ( $tempy );
for ( $x = $dstX ; $x < $dstW ; $x ++ )
{
$tempx = ( $x - $dstX ) * $srcW / $dstW + $srcX;
$tempxr = $tempx - floor ( $tempx );
$tempxl = 1 - $tempxr;
$tempx = floor ( $tempx );
$tempq = imagecolorsforindex ( $src_im , imagecolorat ( $src_im , $tempx , $tempy ) );
$tempw = imagecolorsforindex ( $src_im , imagecolorat ( $src_im , $tempx + 1 , $tempy ) );
$tempa = imagecolorsforindex ( $src_im , imagecolorat ( $src_im , $tempx , $tempy + 1 ) );
$temps = imagecolorsforindex ( $src_im , imagecolorat ( $src_im , $tempx + 1 , $tempy + 1 ) );
$tempq['red'] = $tempq['red'] * $tempxl + $tempw['red'] * $tempxr;
$tempq['green'] = $tempq['green'] * $tempxl + $tempw['green'] * $tempxr;
$tempq['blue'] = $tempq['blue'] * $tempxl + $tempw['blue'] * $tempxr;
$tempa['red'] = $tempa['red'] * $tempxl + $temps['red'] * $tempxr;
$tempa['green'] = $tempa['green'] * $tempxl + $temps['green'] * $tempxr;
$tempa['blue'] = $tempa['blue'] * $tempxl + $temps['blue'] * $tempxr;
$tempq['red'] = $tempq['red'] * $tempyu + $tempa['red'] * $tempyd;
$tempq['green'] = $tempq['green'] * $tempyu + $tempa['green'] * $tempyd;
$tempq['blue'] = $tempq['blue'] * $tempyu + $tempa['blue'] * $tempyd;
imagesetpixel ( $dst_im , $x , $y , imagecolorallocate ( $dst_im , $tempq['red'] , $tempq['green'] , $tempq['blue'] ) );
}
}
}

Note that this function is only for enlarging an image. Depending on the application, you may need to have your script detect whether it will be enlarging or shrinking the image, and use the respective function.
----
Manual Page -- [url]http://www.php.net/manual/en/function.imagecopyresampled.php[/url]
Edit Note -- [url]http://master.php.net/manage/user-notes.php?action=edit+33613[/url]
Delete Note -- [url]http://master.php.net/manage/user-notes.php?action=delete+33613&report=yes[/url]
Reject Note -- [url]http://master.php.net/manage/user-notes.php?action=reject+33613&report=yes[/url]