Skip to content

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

Open

Description

@flyingL123

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.

Activity

  1. tabennett commented on Aug 9, 2016

    @tabennett
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions