diff options
author | plegall <plg@piwigo.org> | 2011-09-17 21:03:58 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2011-09-17 21:03:58 +0000 |
commit | fafb6c336848dcd5955ba3165054f405b8e6d347 (patch) | |
tree | ae27eadafb0b89eb4a614f3a88bdf3950a913b67 /include | |
parent | 3e9f0d74abb745de7ab5248435aa3d1767233b43 (diff) |
feature 2441 added: no need to have the HD to regenerate the websize if the
current websize is bigger than resize settings. When it occurs, we move the
current websize as HD and create the new websize from it.
git-svn-id: http://piwigo.org/svn/trunk@12175 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/ws_functions.inc.php | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 61f655d23..8355ff760 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -2962,7 +2962,7 @@ function ws_images_resizewebsize($params, &$service) include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); $query=' -SELECT id, path, tn_ext, has_high +SELECT id, path, tn_ext, has_high, width, height FROM '.IMAGES_TABLE.' WHERE id = '.(int)$params['image_id'].' ;'; @@ -2974,12 +2974,43 @@ SELECT id, path, tn_ext, has_high } $image_path = $image['path']; - $hd_path = get_high_path($image); - if (empty($image['has_high']) or !file_exists($hd_path) or !is_valid_image_extension(get_extension($image_path))) + if (!is_valid_image_extension(get_extension($image_path))) { return new PwgError(403, "image can't be resized"); } + + $hd_path = get_high_path($image); + + if (empty($image['has_high']) or !file_exists($hd_path)) + { + if ($image['width'] > $params['maxwidth'] or $image['height'] > $params['maxheight']) + { + $hd_path = file_path_for_type($image_path, 'high'); + $hd_dir = dirname($hd_path); + prepare_directory($hd_dir); + + rename($image_path, $hd_path); + $hd_infos = pwg_image_infos($hd_path); + + single_update( + IMAGES_TABLE, + array( + 'has_high' => 'true', + 'high_filesize' => $hd_infos['filesize'], + 'high_width' => $hd_infos['width'], + 'high_height' => $hd_infos['height'], + ), + array( + 'id' => $image['id'] + ) + ); + } + else + { + return new PwgError(403, "image can't be resized"); + } + } $result = false; $img = new pwg_image($hd_path, $params['library']); |