summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-03-26 23:53:48 +0200
committerRobin Appelman <icewind@owncloud.com>2012-03-26 23:53:48 +0200
commit73c6db5c8e6d876adf7b6c1c91049c66be26ba87 (patch)
tree2da6d0e783748b0c9d327ed0a3bdba044b7b8751 /apps/gallery
parent3f881f1ca50b50bb1d564c6bdf55789cda10d4d4 (diff)
downloadnextcloud-server-73c6db5c8e6d876adf7b6c1c91049c66be26ba87.tar.gz
nextcloud-server-73c6db5c8e6d876adf7b6c1c91049c66be26ba87.zip
crop and resize in a single step when creating thumbnail
also so more explicit memory cleanup
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/lib/photo.php11
-rw-r--r--apps/gallery/lib/scanner.php1
2 files changed, 7 insertions, 5 deletions
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index 2263608dcc2..3bb6f9129fa 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -72,6 +72,9 @@ class OC_Gallery_Photo {
$save_dir .= dirname($image_name). '/';
$image_path = $image_name;
$thumb_file = $save_dir . basename($image_name);
+ if (!is_dir($save_dir)) {
+ mkdir($save_dir, 0777, true);
+ }
if (file_exists($thumb_file)) {
$image = new OC_Image($thumb_file);
} else {
@@ -81,17 +84,15 @@ class OC_Gallery_Photo {
}
$image = new OC_Image($image_path);
if ($image->valid()) {
- $image->centerCrop();
- $image->resize(200);
+ $image->centerCrop(200);
$image->fixOrientation();
- if (!is_dir($save_dir)) {
- mkdir($save_dir, 0777, true);
- }
$image->save($thumb_file);
}
}
if ($image->valid()) {
return $image;
+ }else{
+ $image->destroy();
}
return null;
}
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php
index 34b9bb8da3d..6d2d44d428f 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -79,6 +79,7 @@ class OC_Gallery_Scanner {
if ($image && $image->valid()) {
imagecopyresampled($thumbnail, $image->resource(), $i*200, 0, 0, 0, 200, 200, 200, 200);
}
+ $image->destroy();
}
imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png');
imagedestroy($thumbnail);