mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-08 09:43:01 +02:00
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
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user