";
}
return $html;
}
public function deleteThumbFile ($item) {
@chmod($this->thumb_paths[$item], 0646);
unlink($this->thumb_paths[$item]);
@chmod($this->img_paths[$item], 0646);
unlink($this->img_paths[$item]);
}
public function moveAllThumbnails ($fileid) {
if ($this->count == 0) return;
$newpath = remositoryThumbnails::baseFilePath().remositoryThumbnails::dirPattern().$fileid.'/';
for ($item=0; $item<$this->count; $item++) {
@rename($this->thumb_paths[$item], $newpath.preg_replace('/^.+[\\\\\\/]/', '', $this->thumb_paths[$item]));
@rename($this->img_paths[$item], $newpath.preg_replace('/^.+[\\\\\\/]/', '', $this->img_paths[$item]));
}
}
//This function will resize any PNG or JPG image to whatever size you specify
//It will keep aspect ratios.
//usage imgresize(/path/to/sourcefile.png,$destfilename,150,150);
private function imgresize($origfile,$newfile,$new_w,$new_h, $highQuality=false)
{
//determine starting type and create blank
//you could also add gif and bmp in here
$type=remositoryAbstract::lastPart($origfile,'.');
if ($type=="jpg" || $type=="jpeg") $src_img=imagecreatefromjpeg($origfile);
if ($type=="png") $src_img=imagecreatefrompng($origfile);
if ($type=="gif") $src_img=imagecreatefromgif($origfile);
//grab original sizes
$old_x=imagesx($src_img);
$old_y=imagesy($src_img);
// math to figure aspect ratio
$ratio = min($new_w/$old_x, $new_h/$old_y);
$thumb_h = $old_y * $ratio;
$thumb_w = $old_x * $ratio;
//generate a blank final image
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
//this resamples the original image and I think uses bicub to create a new image
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
//unlink it if it already exists in destination
if(file_exists($newfile)) {
chmod($newfile, 0646);
unlink($newfile);
}
//create the final file
if ($type=="png") {
if ($highQuality) imagepng($dst_img,$newfile,0);
else imagepng($dst_img,$newfile);
}
elseif ($type=="gif") imagegif($dst_img,$newfile);
else {
if ($highQuality) imagejpeg($dst_img,$newfile,100);
else imagejpeg($dst_img,$newfile);
}
//free up memory
imagedestroy($dst_img);
imagedestroy($src_img);
}
}