[image processing] missing thumbnail for TIFF on upload form #324

Closed
opened 2026-10-04 23:52:10 +02:00 by adam · 5 comments
Owner

Reported by plg on 21 Apr 2015 11:15

Version: 2.7.4

When upload a TIFF we only get a "missing thumbnail" icon instead of the appropriate thumbnail.

Piwigo Bugtracker #3219

**Reported by plg on 21 Apr 2015 11:15** **Version:** 2.7.4 When upload a TIFF we only get a &quot;missing thumbnail&quot; icon instead of the appropriate thumbnail. [Piwigo Bugtracker #3219](http://piwigo.org/bugs/view.php?id=3219) <!-- github-sync-id:97252356 -->
adam closed this issue 2026-10-04 23:52:11 +02:00
Author
Owner

In file admin/include/image.class.php in write function in image_ext_magick

  function write($destination_filepath)
  {
    global $conf;

    $this->add_command('interlace', 'line'); // progressive rendering
    // use 4:2:2 chroma subsampling (reduce file size by 20-30% with "almost" no human perception)
    //
    // option deactivated for Piwigo 2.4.1, it doesn't work fo old versions
    // of ImageMagick, see bug:2672. To reactivate once we have a better way
    // to detect IM version and when we know which version supports this
    // option
    //
    if (version_compare(pwg_image::$ext_imagick_version, '6.6') > 0)
    {
      $this->add_command('sampling-factor', '4:2:2' );
    }

    $exec = $this->imagickdir.'convert';
    $exec .= ' "'.realpath($this->source_filepath).'"';

    foreach ($this->commands as $command => $params)
    {
      $exec .= ' -'.$command;
      if (!empty($params))
      {
        $exec .= ' '.$params;
      }
    }    

    $dest = pathinfo($destination_filepath);

    $tif_extension = array('tif', 'tiff', 'TIF', 'TIFF');
    if (in_array($dest['extension'], $tif_extension))
    {
        $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['filename'].'.'.$conf['tiff_representative_ext'].'" 2>&1';
    }
    else
    {
        $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1';
    }

    @exec($exec, $returnarray);    

    if (function_exists('ilog')) ilog($exec);
    if (is_array($returnarray) && (count($returnarray)>0) )
    {
      if (function_exists('ilog')) ilog('ERROR', $returnarray);
      foreach($returnarray as $line)
        trigger_error($line, E_USER_WARNING);
    }
    return is_array($returnarray);
  }
}

In include/derivative.inc.php, SrcImage class. If $conf['picture_ext'] contains tif, tiff, TIF, TIFF extensions, displaying error occurs. With this modifcation it's ok.

  function __construct($infos)
  {
    global $conf;

    $this->id = $infos['id'];
    $ext = get_extension($infos['path']);

    $tif_ext = array('tif', 'tiff', 'TIF', 'TIFF');
    if (in_array($ext, $conf['picture_ext']) AND (!in_array($ext, $tif_ext)))
    {
      $this->rel_path = $infos['path'];
      $this->flags |= self::IS_ORIGINAL;
    }
    elseif (!empty($infos['representative_ext']))
    {
      $this->rel_path = original_to_representative($infos['path'], $infos['representative_ext']);
    }
    else
    {
      $ext = strtolower($ext);
      $this->rel_path = trigger_change('get_mimetype_location', get_themeconf('mime_icon_dir').$ext.'.png', $ext );
      $this->flags |= self::IS_MIMETYPE;
      if ( ($size=@getimagesize(PHPWG_ROOT_PATH.$this->rel_path)) === false)
      {
        $this->rel_path = 'themes/default/icon/mimetypes/unknown.png';
        $size = getimagesize(PHPWG_ROOT_PATH.$this->rel_path);
      }
      $this->size = array($size[0],$size[1]);
    }

    if (!$this->size)
    {
      if (isset($infos['width']) && isset($infos['height']))
      {
        $width = $infos['width'];
        $height = $infos['height'];

        $this->rotation = intval($infos['rotation']) % 4;
        // 1 or 5 =>  90 clockwise
        // 3 or 7 => 270 clockwise
        if ($this->rotation % 2)
        {
          $width = $infos['height'];
          $height = $infos['width'];
        }

        $this->size = array($width, $height);
      }
      elseif (!array_key_exists('width', $infos))
      {
        $this->flags |= self::DIM_NOT_GIVEN;
      }
    }
  }
In file admin/include/image.class.php in write function in image_ext_magick ``` php function write($destination_filepath) { global $conf; $this->add_command('interlace', 'line'); // progressive rendering // use 4:2:2 chroma subsampling (reduce file size by 20-30% with "almost" no human perception) // // option deactivated for Piwigo 2.4.1, it doesn't work fo old versions // of ImageMagick, see bug:2672. To reactivate once we have a better way // to detect IM version and when we know which version supports this // option // if (version_compare(pwg_image::$ext_imagick_version, '6.6') > 0) { $this->add_command('sampling-factor', '4:2:2' ); } $exec = $this->imagickdir.'convert'; $exec .= ' "'.realpath($this->source_filepath).'"'; foreach ($this->commands as $command => $params) { $exec .= ' -'.$command; if (!empty($params)) { $exec .= ' '.$params; } } $dest = pathinfo($destination_filepath); $tif_extension = array('tif', 'tiff', 'TIF', 'TIFF'); if (in_array($dest['extension'], $tif_extension)) { $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['filename'].'.'.$conf['tiff_representative_ext'].'" 2>&1'; } else { $exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1'; } @exec($exec, $returnarray); if (function_exists('ilog')) ilog($exec); if (is_array($returnarray) && (count($returnarray)>0) ) { if (function_exists('ilog')) ilog('ERROR', $returnarray); foreach($returnarray as $line) trigger_error($line, E_USER_WARNING); } return is_array($returnarray); } } ``` In include/derivative.inc.php, SrcImage class. If $conf['picture_ext'] contains tif, tiff, TIF, TIFF extensions, displaying error occurs. With this modifcation it's ok. ``` php function __construct($infos) { global $conf; $this->id = $infos['id']; $ext = get_extension($infos['path']); $tif_ext = array('tif', 'tiff', 'TIF', 'TIFF'); if (in_array($ext, $conf['picture_ext']) AND (!in_array($ext, $tif_ext))) { $this->rel_path = $infos['path']; $this->flags |= self::IS_ORIGINAL; } elseif (!empty($infos['representative_ext'])) { $this->rel_path = original_to_representative($infos['path'], $infos['representative_ext']); } else { $ext = strtolower($ext); $this->rel_path = trigger_change('get_mimetype_location', get_themeconf('mime_icon_dir').$ext.'.png', $ext ); $this->flags |= self::IS_MIMETYPE; if ( ($size=@getimagesize(PHPWG_ROOT_PATH.$this->rel_path)) === false) { $this->rel_path = 'themes/default/icon/mimetypes/unknown.png'; $size = getimagesize(PHPWG_ROOT_PATH.$this->rel_path); } $this->size = array($size[0],$size[1]); } if (!$this->size) { if (isset($infos['width']) && isset($infos['height'])) { $width = $infos['width']; $height = $infos['height']; $this->rotation = intval($infos['rotation']) % 4; // 1 or 5 => 90 clockwise // 3 or 7 => 270 clockwise if ($this->rotation % 2) { $width = $infos['height']; $height = $infos['width']; } $this->size = array($width, $height); } elseif (!array_key_exists('width', $infos)) { $this->flags |= self::DIM_NOT_GIVEN; } } } ``` <!-- github-comment-id:140373076 -->
Author
Owner

I just made a new test (on current git master) and the problem does not occur. I have to make so more tests.

I just made a new test (on current git master) and the problem does not occur. I have to make so more tests. <!-- github-comment-id:164532485 -->
Author
Owner

I have made another test on Piwigo 2.7 and I can't reproduce any problem. If you have $conf['graphics_library'] = 'ext_imagick'; then a pwg_representative will be created during upload and Piwigo will generate the thumbnail from it.

I have made another test on Piwigo 2.7 and I can't reproduce any problem. If you have $conf['graphics_library'] = 'ext_imagick'; then a pwg_representative will be created during upload and Piwigo will generate the thumbnail from it. <!-- github-comment-id:164549401 -->
Author
Owner

As I can't reproduce the bug on Git master, I close this issue.

As I can't reproduce the bug on Git master, I close this issue. <!-- github-comment-id:184763172 -->
Author
Owner

Sorry to reply so late. I did a test with the new version 2.8 and I still have the same error for the generation of thumbnail tiff formats.

Sample video : http://blogoflip.fr/mespartages/index.php/s/VrRZzwwOqfstpkd

Sorry to reply so late. I did a test with the new version 2.8 and I still have the same error for the generation of thumbnail tiff formats. Sample video : http://blogoflip.fr/mespartages/index.php/s/VrRZzwwOqfstpkd <!-- github-comment-id:194324518 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#324