PHP Classes

Added method

Recommend this page to a friend!

      Thumbnail Images  >  All threads  >  Added method  >  (Un) Subscribe thread alerts  
Subject:Added method
Summary:A suggestion and an added method
Messages:1
Author:Steven
Date:2007-05-21 05:38:25
 

  1. Added method   Reply   Report abuse  
Picture of Steven Steven - 2007-05-21 05:38:25
I think you might want to look at shorter names such as:
create() instead of create_thumbnail_images() (creating thumbnails is all it does)

I added this function at line 40 to create a thumbnail that fits into the specified box without distortion.

// Fit to box function
function create_fitted_thumbnail($NewWidth, $NewHeight) {
$Oldsize = @getimagesize($this->PathImgOld);
$OldWidth = $Oldsize[0];
$OldHeight = $Oldsize[1];
$reduceW = $OldWidth/$NewWidth;
$reduceH = $OldHeight/$NewHeight;
if ($reduceW > $reduceH) {
$this->NewWidth = round($OldWidth/$reduceW);
$this->NewHeight = round($OldHeight/$reduceW);
} else {
$this->NewWidth = round($OldWidth/$reduceH);
$this->NewHeight = round($OldHeight/$reduceH);
}
if ($this->create_thumbnail_images()) {
return true;
} else {
return false;
}
}