Return to Snippet

Revision: 2977
at May 19, 2007 11:32 by iloveitaly


Initial Code
<?php
require_once "Image/Transform/Driver/GD.php";

if(isset($_GET['p']) && isset($_GET['s'])) {
	$path = "thumbs/".$_GET['p'];
	$sideSize = (int)$_GET['s'];
		
	$image = new Image_Transform_Driver_GD();
	$image->load($path);
	
	if($image->getImageWidth() > $image->getImageHeight()) {
		$image->scaleByY($sideSize);
		$result = $image->crop($sideSize, $sideSize, ($image->new_x - $sideSize)/2, 0);
	} else {
		$image->scaleByX($sideSize);
		$image->crop($sideSize, $sideSize, 0, ($image->new_y - $sideSize)/2);
	}
	
	$image->display();
} else {
	trigger_error("Bad GET vars");
}
?>

Initial URL

                                

Initial Description
example: thumb.php?p=image.jpg&s=45

Initial Title
Image Thumbnail with GD & GET vars

Initial Tags
php, image

Initial Language
PHP