CodeSleeve / stapler

ORM-based file upload package for php.
http://codesleeve.com
Other
538 stars 144 forks source link

How to define style with callable and still control image quality #162

Open flyingL123 opened 8 years ago

flyingL123 commented 8 years ago

Is it possible to define a style as a callable, but still control the quality of the resized image?

I have the following styles defined:


'styles' => [
    'thumbnail' => [
        'dimensions' => '300',
        'auto_orient' => true,
        'convert_options' => ['quality' => 100],
    ],
    'zoom' => function($file, $imagine) {
        $image = $imagine->open($file->getRealPath());
        $filter = new \Imagine\Filter\Basic\Autorotate;
        $filter->apply($image);
        $size = $image->getSize();

        if ($size->getWidth() > 1280) {
            return $image->thumbnail(new \Imagine\Image\Box(1280, 1280), \Imagine\Image\ImageInterface::THUMBNAIL_INSET);
        }

        return $image;
    }
],

I would like to ensure that the zoom styles uses a quality = 100, just like the thumbnail style does. Is there any way to specify this? I can't figure out how to do it in the callable, since the quality is normally set when the image is saved.

tabennett commented 8 years ago

I don't currently have a way to do this. I'll try and work this into the 2.0 release that's coming up.