summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Denhardt <ian@zenhack.net>2010-08-03 19:24:19 -0400
committerIan Denhardt <ian@zenhack.net>2010-08-03 19:24:19 -0400
commit727758d27529c6423fd885698094507a8d190ac4 (patch)
treed2145dce85c912f8e87578ee20ef30641c86c83d
parentab46007709c3a683759c583d43e0bbdf6181e6d2 (diff)
Fixed scaling. thumbnails are bigger now, too.
-rw-r--r--plugins/GNUsocialPhotos/actions/photos.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/plugins/GNUsocialPhotos/actions/photos.php b/plugins/GNUsocialPhotos/actions/photos.php
index 1c7fb82bd..c8b33230e 100644
--- a/plugins/GNUsocialPhotos/actions/photos.php
+++ b/plugins/GNUsocialPhotos/actions/photos.php
@@ -110,8 +110,8 @@ class PhotosAction extends Action
function makeThumb($filename)
{
- $height_dest = 96;
- $width_dest = 128;
+ $height_dest = 192;
+ $width_dest = 256;
if (substr($filename, -4) == '.jpg' || substr($filename, -5) == '.jpeg') {
$image_src = imagecreatefromjpeg(INSTALLDIR . '/file/' . $filename);
@@ -128,8 +128,24 @@ class PhotosAction extends Action
$image_dest = imagecreatetruecolor($width_dest, $height_dest);
$size_src = getimagesize(INSTALLDIR . '/file/' . $filename);
-
- imagecopyresampled($image_dest, $image_src, 0, 0, 0, 0, $width_dest, $height_dest, $size_src[0], $size_src[1]);
+ $width_src = $size_src[0];
+ $height_src = $size_src[1];
+
+ // We want to make the image as big as possible without distortion.
+ $width_hmax = $width_src / ((float)$height_src / (float)$height_dest);
+ $height_wmax = $height_src / ((float)$width_src / (float)$width_dest);
+
+
+ if ($width_hmax > $width_dest) {
+ $width_hmax = $width_dest;
+ } else {
+ $height_wmax = $height_dest;
+ }
+
+ common_log(LOG_INFO, 'height_wmax = ' . $height_wmax);
+ common_log(LOG_INFO, 'width_hmax = ' . $width_hmax);
+
+ imagecopyresampled($image_dest, $image_src, 0, 0, 0, 0, (int)($width_hmax), (int)($height_wmax), $width_src, $height_src);
switch ($image_type) {
case IMAGETYPE_JPEG:
imagejpeg($image_dest, INSTALLDIR . '/file/' . 'thumb.' . $filename, 100);