2

I use craft transformations for resizing images. The transformation of jpg files works as exepted, but the transformation of a tif image does not work. Imagick is installed and in the backend it creats and shows thumbnails of the images. When i rename the image from .tif to .jpg it performs the transformation also.

The Twig code looks like this:

<img src="{{ entry.getUrl('preview') }}" width="200" height="200">

The output HTML Code of a tif image looks like this:

<img src="http://www.am-sb-coop.ch/internal/img/AM_HC16_KW00_Broccoli_rl_ZTG_DL.tif" width="200" height="200">

The output HTML Code of a jpg image looks like this: <img src="http://www.am-sb-coop.ch/internal/img/_preview/AM_FOOD_KW28_Prix_Gar_Konfi_mg_01_ZTG_DL.jpg" width="200" height="200">

Is this a bug or have i missed a config setting?

Here are some images for explanation:

Output in Browser Backend shows Thumbnails Transformation settings

3 Answers 3

3

As of version 2.5.2750 it appears Craft now comes with sample files to check against isImageManipulatable() in /craft/app/helpers/ImageHelper.php which includes the following files located at /craft/app/resources/images/samples/ by default:

  • sample.bmp
  • sample.gif
  • sample.jpeg
  • sample.jpg
  • sample.png
  • sample.svg
  • sample.tif
  • sample.tiff

If the installed Imagick includes support for tif files it will be able to transform these without any extra configuration or hacking of the isImageManipulatable() function which was the only previous method of enabling transforms for tif. Previous answer by @TomBauer.

Note: It looks like you should be able to add support for extra files in Craft (if supported by installed Imagick) by providing a sample file in the above directory for Craft to check against. At least until Craft updates.

3

I found the way to create thumbnails of tif files. You have to change the function isImageManipulatable in the file /craft/app/helpers/ImageHelper.php:

public static function isImageManipulatable($extension)
{
    $extensions = array('jpg', 'jpeg', 'gif', 'png', 'wbmp', 'xbm');

   if (craft()->images->isImagick())
    {
        $extensions[] = 'svg';
    }

    return in_array(mb_strtolower($extension), $extensions);

}

To this:

public static function isImageManipulatable($extension)
{
    $extensions = array('jpg', 'jpeg', 'gif', 'png', 'wbmp', 'xbm');

   if (craft()->images->isImagick())
    {
        $extensions[] = 'svg';
        $extensions[] = 'tif';
    }

    return in_array(mb_strtolower($extension), $extensions);

}

I know, changing core code is not a real solution: i posted this change as a Craft feature request -> http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/8794456-better-support-of-image-types-in-image-transformat

2
  • Whether or not tif is supported depends on Imagick configuration. TIFF also requires an external library (imagemagick.org/script/formats.php) so it most likely is not one of the formats supported by default on most hosts. Perhaps we'll add a config setting that would allow you to define additional extensions, but I can't give any guarantees. Commented Jul 23, 2015 at 11:56
  • A config setting would be realy great! Thx for "check" this option.
    – Tom Bauer
    Commented Jul 31, 2015 at 6:12
1

Currently, only jpg, jpeg, gif, png, wbmp and xbm files are supported for image transforms using Imagick and GD. Additionally, if you have Imagick installed, Craft will also transform svg files.

1
  • 1
    Thank you for your explanation. I found now a way to create the thumbnails from tif files. See solution above.
    – Tom Bauer
    Commented Jul 10, 2015 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.