aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions_upload.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/include/functions_upload.inc.php')
-rw-r--r--admin/include/functions_upload.inc.php78
1 files changed, 60 insertions, 18 deletions
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php
index a23977910..40a53adf9 100644
--- a/admin/include/functions_upload.inc.php
+++ b/admin/include/functions_upload.inc.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
@@ -122,13 +122,9 @@ function save_upload_form_config($data, &$errors=array(), &$form_errors=array())
}
else
{
- array_push(
- $errors,
- sprintf(
- $upload_form_config[$field]['error_message'],
- $min,
- $max
- )
+ $errors[] = sprintf(
+ $upload_form_config[$field]['error_message'],
+ $min, $max
);
$form_errors[$field] = '['.$min.' .. '.$max.']';
@@ -175,6 +171,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
}
$file_path = null;
+ $is_tiff = false;
if (isset($image_id))
{
@@ -230,6 +227,11 @@ SELECT
{
$file_path.= 'gif';
}
+ elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type)
+ {
+ $is_tiff = true;
+ $file_path.= 'tif';
+ }
else
{
$file_path.= 'jpg';
@@ -248,6 +250,50 @@ SELECT
}
@chmod($file_path, 0644);
+ if ($is_tiff and pwg_image::get_library() == 'ext_imagick')
+ {
+ // move the uploaded file to pwg_representative sub-directory
+ $representative_file_path = dirname($file_path).'/pwg_representative/';
+ $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.';
+
+ $representative_ext = $conf['tiff_representative_ext'];
+ $representative_file_path.= $representative_ext;
+
+ prepare_directory(dirname($representative_file_path));
+
+ $exec = $conf['ext_imagick_dir'].'convert';
+
+ if ('jpg' == $conf['tiff_representative_ext'])
+ {
+ $exec .= ' -quality 98';
+ }
+
+ $exec .= ' "'.realpath($file_path).'"';
+
+ $dest = pathinfo($representative_file_path);
+ $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
+
+ $exec .= ' 2>&1';
+ @exec($exec, $returnarray);
+
+ // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg
+ // (thumbnail). I don't know how to avoid it.
+ $representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename'];
+ if (!file_exists($representative_file_abspath))
+ {
+ $first_file_abspath = preg_replace(
+ '/\.'.$representative_ext.'$/',
+ '-0.'.$representative_ext,
+ $representative_file_abspath
+ );
+
+ if (file_exists($first_file_abspath))
+ {
+ rename($first_file_abspath, $representative_file_abspath);
+ }
+ }
+ }
+
if (pwg_image::get_library() != 'gd')
{
if ($conf['original_resize'])
@@ -324,6 +370,11 @@ SELECT
$insert['level'] = $level;
}
+ if (isset($representative_ext))
+ {
+ $insert['representative_ext'] = $representative_ext;
+ }
+
single_insert(IMAGES_TABLE, $insert);
$image_id = pwg_db_insert_id(IMAGES_TABLE);
@@ -494,16 +545,7 @@ function convert_shorthand_notation_to_bytes($value)
function add_upload_error($upload_id, $error_message)
{
- if (!isset($_SESSION['uploads_error']))
- {
- $_SESSION['uploads_error'] = array();
- }
- if (!isset($_SESSION['uploads_error'][$upload_id]))
- {
- $_SESSION['uploads_error'][$upload_id] = array();
- }
-
- array_push($_SESSION['uploads_error'][$upload_id], $error_message);
+ $_SESSION['uploads_error'][$upload_id][] = $error_message;
}
function ready_for_upload_message()