Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flyingL123 opened this issue Jul 18, 2016 · 1 comment
Open

Comments

@flyingL123
Copy link

flyingL123 commented Jul 18, 2016

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
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants