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

Quality for image manipulation #53

Merged
merged 1 commit into from
Aug 2, 2016
Merged

Conversation

motchju
Copy link
Contributor

@motchju motchju commented Aug 2, 2016

Use the quality option for the stream function:

public Intervention\Image\Image stream([mixed $format, [int $quality]])

By default, we still have the default behavior (value of 90 for the image quality)

If you define a filter (see https://asgardcms.com/docs/v1/media-module/thumbnails#crop) you might set a different quality

Basic usage

return [
    'smallThumb' => [
        'quality' => 50,
        'crop' => [
            'width' => '100',
            'height' => '200'
        ],
        'blur' => [
            'amount' => '15'
        ],
    ]
];

As mentioned in the doc it's only for JPG

Define the quality of the encoded image optionally. Data ranging from 0 (poor quality, small file) to 100 (best quality, big file). Quality is only applied if you're encoding JPG format since PNG compression is lossless and does not affect image quality. Default: 90.

@@ -105,7 +105,7 @@ public function createAll(MediaPath $path)
foreach ($thumbnail->filters() as $manipulation => $options) {
$image = $this->imageFactory->make($manipulation)->handle($image, $options);
}
$image = $image->stream(pathinfo($path, PATHINFO_EXTENSION));
$image = $image->stream(pathinfo($path, PATHINFO_EXTENSION), array_get($thumbnail->filters(), 'quality', 90));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #54 :)

@nWidart nWidart merged commit f81e043 into AsgardCms:master Aug 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants