diff options
author | plegall <plg@piwigo.org> | 2013-12-12 10:34:55 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2013-12-12 10:34:55 +0000 |
commit | 483cce26121918960163e501b4feb132572cc76d (patch) | |
tree | ffa138420b7c9d51a0a0e6038c7b59cc5ebf4988 /admin | |
parent | 97371a948ae1d212a61c8200ce93380d39ee2fa1 (diff) |
feature 2869 added: support TIFF files on web upload (requires ext_imagick)
git-svn-id: http://piwigo.org/svn/trunk@25929 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r-- | admin/include/functions_upload.inc.php | 55 | ||||
-rw-r--r-- | admin/include/photos_add_direct_prepare.inc.php | 7 | ||||
-rw-r--r-- | admin/themes/default/template/photos_add_direct.tpl | 2 |
3 files changed, 63 insertions, 1 deletions
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index d136e8928..ab0f467fb 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -171,6 +171,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie } $file_path = null; + $is_tiff = false; if (isset($image_id)) { @@ -226,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'; @@ -244,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']) @@ -320,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); diff --git a/admin/include/photos_add_direct_prepare.inc.php b/admin/include/photos_add_direct_prepare.inc.php index 6b53aaa83..bd4dc23dd 100644 --- a/admin/include/photos_add_direct_prepare.inc.php +++ b/admin/include/photos_add_direct_prepare.inc.php @@ -144,6 +144,13 @@ $template->assign( ); $upload_file_types = 'jpeg, png, gif'; + +if (pwg_image::get_library() == 'ext_imagick') +{ + $upload_file_types.= ', tiff'; + $template->assign('tif_enabled', true); +} + if ('html' == $upload_mode) { $upload_file_types.= ', zip'; diff --git a/admin/themes/default/template/photos_add_direct.tpl b/admin/themes/default/template/photos_add_direct.tpl index ef9582f2e..c63f9dec7 100644 --- a/admin/themes/default/template/photos_add_direct.tpl +++ b/admin/themes/default/template/photos_add_direct.tpl @@ -127,7 +127,7 @@ var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */ 'auto' : false, 'multi' : true, 'fileTypeDesc' : 'Photo files', - 'fileTypeExts' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF', + 'fileTypeExts' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF;{/literal}{if $tif_enabled}*.tif;*.TIF;*.tiff;*.TIFF{/if}{literal}', 'fileSizeLimit' : sizeLimit, 'progressData' : 'percentage', requeueErrors : false, |