function resizeimage in Brilliant Gallery 7
Same name and namespace in other branches
- 5.4 image.php \resizeimage()
- 5.3 image.php \resizeimage()
- 6.4 functions.inc \resizeimage()
- 6 image.php \resizeimage()
- 6.2 image.php \resizeimage()
- 6.3 image.php \resizeimage()
- 7.2 OLD_brilliant_gallery_functions.inc \resizeimage()
1 call to resizeimage()
File
- ./
brilliant_gallery_functions.inc, line 260
Code
function resizeimage($imgp, $imgw, $imgh, $imgcrop, $imagepath) {
$imagepathexploded = explode('.', strtolower($imagepath));
$suffix = end($imagepathexploded);
if ($suffix == "gif") {
$img = @imagecreatefromgif($imagepath);
if (!$img) {
brilliant_gallery_brokenimage("Error loading GIF", $imgw, $imgh);
}
}
else {
if ($suffix == "jpg" or $suffix == "jpeg") {
$img = @imagecreatefromjpeg($imagepath);
if (!$img) {
brilliant_gallery_brokenimage("Error loading JPG", $imgw, $imgh);
}
}
else {
if ($suffix == "png") {
$img = @imagecreatefrompng($imagepath);
if (!$img) {
brilliant_gallery_brokenimage("Error loading PNG", $imgw, $imgh);
}
}
}
}
# Resize the image
$src_h = ImageSY($img);
$src_w = ImageSX($img);
$dst_img = 0;
if ($imgcrop == 'yes') {
if ($src_h > $src_w) {
// portrait
$dst_img = imagecreatetruecolor($imgh, $imgh);
imagecopyresampled($dst_img, $img, 0, 0, 0, ($src_h - $src_w) / 2, $imgh, $imgh, $src_w, $src_w);
}
else {
// landscape
$dst_img = imagecreatetruecolor($imgw, $imgw);
imagecopyresampled($dst_img, $img, 0, 0, ($src_w - $src_h) / 2, 0, $imgw, $imgw, $src_h, $src_h);
}
}
else {
$dst_img = imagecreatetruecolor($imgw, $imgh);
imagecopyresampled($dst_img, $img, 0, 0, 0, 0, $imgw, $imgh, $src_w, $src_h);
}
$img = $dst_img;
ob_start();
if ($suffix == "gif") {
Imagegif($img);
}
else {
if ($suffix == "jpg" or $suffix == "jpeg") {
Imagejpeg($img, NULL, 90);
}
else {
if ($suffix == "png") {
Imagepng($img, NULL, 9);
}
}
}
$result = ob_get_clean();
#ImageDestroy($img);
$result = $result;
return $result;
}