All pastes #508388 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-25 00:03 UTC
rendered paste body
$source = "test.jpg";
    $thumb_size = 70;
    $size = getimagesize($source);
    $width = $size[0];
    $height = $size[1];
 
    if($width> $height) {
        $x = ceil(($width - $height) / 2 );
        $width = $height;
    } elseif($height> $width) {
        $y = ceil(($height - $width) / 2);
        $height = $width;
    }
 
    $new_im = ImageCreatetruecolor($thumb_size,$thumb_size);
    $im = imagecreatefromjpeg($source);
    imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
 	header("Content-Type: image/png");
	imagepng($new_im);