05-19-2008, 09:38 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by delayedinsanity
Okay, so theirs isn't just resizing, it's cropping too, based on what size you enter... so this is pretty close, all mine does is resize it, but I just woke up. I think they're probably using some kind of math to figure out a crop area based on the ratio of the size entered. I didn't tinker with that at all. Also i'm not sure if you can dynamically display the new image without saving it as an actual physical file somewhere. If you can, I'd love to know how, if anybody knows?
PHP Code:
<?php
function thumbnail ($szFile, $intNewWidth, $intNewHeight) {
$aImg = getimagesize($szFile);
$intWidth = $aImg[0];
$intHeight = $aImg[1];
$szFileType = $aImg['mime'];
unset($aImg);
switch ($szFileType) {
case "image/pjpeg": case "image/jpeg": $imgNew = imagecreatefromjpeg($szFile); break;
case "image/x-png": case "image/png": $imgNew = imagecreatefrompng($szFile); break;
case "image/gif": $imgNew = imagecreatefromgif($szFile); break;
default: return false;
}
$imgResized = imagecreatetruecolor($intNewWidth, $intNewHeight);
imagecopyresampled($imgResized, $imgNew, 0, 0, 0, 0, $intNewWidth, $intNewHeight, $intWidth, $intHeight);
if (imagejpeg($imgResized, "temp/temp.jpg", 100)) {
imagedestroy($imgResized);
imagedestroy($imgNew);
return true;
} else {
imagedestroy($imgResized);
imagedestroy($imgNew);
return false;
}
} // thumbnail()
$file = "path/to/your.jpg";
thumbnail($file, $_GET['w'], $_GET['h']);
?>
<img src="temp/temp.jpg" />
-m
|
I have no idea, I know the person who made the site though, all he told me was he kept the aspect ratio the same, though I did that, and it still looks like shit. :P his is better. and he said to do it, was just math. -_- ugh.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|