Location: PHPKode > scripts > Square Images (Flickr Style) > square-images-flickr-style/index.php
<?php

function sqThm($src,$dest,$size=75){

			$squareSize = 70;
			
			list($w,$h) = getimagesize($src);
			
			if($w > $h){
			   exec("convert ".$src." -resize x".$size." -quality 100 ".$dest);
			}else{
			   exec("convert ".$src." -resize ".$size." -quality 100 ".$dest);
			}
			
			exec("convert ".$dest." -gravity Center -crop ".$size."x".$size."+0+0 ".$dest);

}

if(!$_GET[imgtosquare]){

   print "
   <p>Click on the image you want to conver to a square.</p>
   <p><a href='index.php?imgtosquare=1'><img src='gfx/1.jpg' border='0'></a></p>
   <p><a href='index.php?imgtosquare=2'><img src='gfx/2.jpg' border='0'></a></p>
   ";

}else{

   if($_GET[imgtosquare] != '1' && $_GET[imgtosquare] != '2'){ exit; }

   sqThm("gfx/".$_GET[imgtosquare].".jpg","gfx/".$_GET[imgtosquare]."_squared.jpg");
   
   print "
   <p>Here is your squared image.</p>
   <p><img src='gfx/".$_GET[imgtosquare]."_squared.jpg' border='0'></p>
   ";

}

?>
Return current item: Square Images (Flickr Style)