Changeset 25929 for trunk/admin/include


Ignore:
Timestamp:
Dec 12, 2013, 11:34:55 AM (11 years ago)
Author:
plg
Message:

feature 2869 added: support TIFF files on web upload (requires ext_imagick)

Location:
trunk/admin/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r25018 r25929  
    172172
    173173  $file_path = null;
     174  $is_tiff = false;
    174175
    175176  if (isset($image_id))
     
    227228      $file_path.= 'gif';
    228229    }
     230    elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type)
     231    {
     232      $is_tiff = true;
     233      $file_path.= 'tif';
     234    }
    229235    else
    230236    {
     
    244250  }
    245251  @chmod($file_path, 0644);
     252
     253  if ($is_tiff and pwg_image::get_library() == 'ext_imagick')
     254  {
     255    // move the uploaded file to pwg_representative sub-directory
     256    $representative_file_path = dirname($file_path).'/pwg_representative/';
     257    $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.';
     258
     259    $representative_ext = $conf['tiff_representative_ext'];
     260    $representative_file_path.= $representative_ext;
     261
     262    prepare_directory(dirname($representative_file_path));
     263   
     264    $exec = $conf['ext_imagick_dir'].'convert';
     265
     266    if ('jpg' == $conf['tiff_representative_ext'])
     267    {
     268      $exec .= ' -quality 98';
     269    }
     270   
     271    $exec .= ' "'.realpath($file_path).'"';
     272
     273    $dest = pathinfo($representative_file_path);
     274    $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
     275   
     276    $exec .= ' 2>&1';
     277    @exec($exec, $returnarray);
     278
     279    // sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg
     280    // (thumbnail). I don't know how to avoid it.
     281    $representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename'];
     282    if (!file_exists($representative_file_abspath))
     283    {
     284      $first_file_abspath = preg_replace(
     285        '/\.'.$representative_ext.'$/',
     286        '-0.'.$representative_ext,
     287        $representative_file_abspath
     288        );
     289     
     290      if (file_exists($first_file_abspath))
     291      {
     292        rename($first_file_abspath, $representative_file_abspath);
     293      }
     294    }
     295  }
    246296
    247297  if (pwg_image::get_library() != 'gd')
     
    319369    {
    320370      $insert['level'] = $level;
     371    }
     372
     373    if (isset($representative_ext))
     374    {
     375      $insert['representative_ext'] = $representative_ext;
    321376    }
    322377
  • trunk/admin/include/photos_add_direct_prepare.inc.php

    r25593 r25929  
    145145
    146146$upload_file_types = 'jpeg, png, gif';
     147
     148if (pwg_image::get_library() == 'ext_imagick')
     149{
     150  $upload_file_types.= ', tiff';
     151  $template->assign('tif_enabled', true);
     152}
     153
    147154if ('html' == $upload_mode)
    148155{
Note: See TracChangeset for help on using the changeset viewer.