/ Published in: PHP
example: thumb.php?p=image.jpg&s=45
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php require_once "Image/Transform/Driver/GD.php"; $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 { } ?>