bug 2615 php notice in calendar amd web service

multisize improve handling of cases where the original is smaller than a requested derivative, but rotation/watermarking is required

git-svn-id: http://piwigo.org/svn/trunk@14143 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2012-04-14 04:52:20 +00:00
parent 10bf036231
commit 1b54eb8e9c
4 changed files with 34 additions and 8 deletions

View file

@ -734,7 +734,7 @@ if (count($page['cat_elements_id']) > 0)
$query = ' $query = '
SELECT id,path,representative_ext,file,filesize,level,name SELECT id,path,representative_ext,file,filesize,level,name,width,height,rotation
FROM '.IMAGES_TABLE; FROM '.IMAGES_TABLE;
if ($is_category) if ($is_category)

View file

@ -350,7 +350,7 @@ function build_month_calendar(&$tpl_var)
{ {
$page['chronology_date'][CDAY]=$day; $page['chronology_date'][CDAY]=$day;
$query = ' $query = '
SELECT id, file,representative_ext,path,width, height, '.pwg_db_get_dayofweek($this->date_field).'-1 as dow'; SELECT id, file,representative_ext,path,width,height,rotation, '.pwg_db_get_dayofweek($this->date_field).'-1 as dow';
$query.= $this->inner_sql; $query.= $this->inner_sql;
$query.= $this->get_date_where(); $query.= $this->get_date_where();
$query.= ' $query.= '
@ -392,6 +392,10 @@ SELECT id, file,representative_ext,path,width, height, '.pwg_db_get_dayofweek($t
} }
list($cell_width, $cell_height) = ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size; list($cell_width, $cell_height) = ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size;
if ($cell_width>120)
{
$cell_width = $cell_height = 120;
}
$tpl_weeks = array(); $tpl_weeks = array();
$tpl_crt_week = array(); $tpl_crt_week = array();

View file

@ -26,6 +26,7 @@ final class SrcImage
public $id; public $id;
public $rel_path; public $rel_path;
public $rotation = 0;
private $size=null; private $size=null;
private $flags=0; private $flags=0;
@ -58,9 +59,10 @@ final class SrcImage
$width = $infos['width']; $width = $infos['width'];
$height = $infos['height']; $height = $infos['height'];
$this->rotation = intval($infos['rotation']) % 4;
// 1 or 5 => 90 clockwise // 1 or 5 => 90 clockwise
// 3 or 7 => 270 clockwise // 3 or 7 => 270 clockwise
if ($infos['rotation'] % 2 != 0) if ($this->rotation % 2)
{ {
$width = $infos['height']; $width = $infos['height'];
$height = $infos['width']; $height = $infos['width'];
@ -173,10 +175,30 @@ final class DerivativeImage
{ {
if ( $src->has_size() && $params->is_identity( $src->get_size() ) ) if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
{ {
// todo - what if we have a watermark maybe return a smaller size? if (!$params->use_watermark && !$src->rotation)
$params = null; {
$rel_path = $rel_url = $src->rel_path; $params = null;
return; $rel_path = $rel_url = $src->rel_path;
return;
}
$defined_types = array_keys(ImageStdParams::get_defined_type_map());
for ($i=0; $i<count($defined_types); $i++)
{
if ($defined_types[$i] == $params->type)
{
for ($i--; $i>=0; $i--)
{
$smaller = ImageStdParams::get_by_type($defined_types[$i]);
if ($smaller->sizing->max_crop==$params->sizing->max_crop && $smaller->is_identity( $src->get_size() ))
{
$params = $smaller;
self::build($src, $params, $rel_path, $rel_url, $is_cached);
return;
}
}
break;
}
}
} }
$tokens=array(); $tokens=array();

View file

@ -224,7 +224,7 @@ function ws_getMissingDerivatives($params, &$service)
$where_clauses[] = 'id IN ('.implode(',',$params['ids']).')'; $where_clauses[] = 'id IN ('.implode(',',$params['ids']).')';
} }
$query_model = 'SELECT id, path, representative_ext, width, height $query_model = 'SELECT id, path, representative_ext, width,height,rotation
FROM '.IMAGES_TABLE.' FROM '.IMAGES_TABLE.'
WHERE '.implode(' AND ', $where_clauses).' WHERE '.implode(' AND ', $where_clauses).'
ORDER BY id DESC ORDER BY id DESC