Skip to content

Comments

Take the extension from options into account when saving the image#9

Closed
mjauvin wants to merge 4 commits intowintercms:developfrom
mjauvin:use-extension-for-type-conversion
Closed

Take the extension from options into account when saving the image#9
mjauvin wants to merge 4 commits intowintercms:developfrom
mjauvin:use-extension-for-type-conversion

Conversation

@mjauvin
Copy link
Member

@mjauvin mjauvin commented Mar 17, 2021

@mjauvin mjauvin added this to the v1.1.3 milestone Mar 19, 2021
@LukeTowers LukeTowers modified the milestones: v1.1.3, v1.2.0, v1.1.4 Apr 1, 2021
@mjauvin
Copy link
Member Author

mjauvin commented May 7, 2021

@LukeTowers This is required to allow converting images to other formats (e.g. webp). Otherwise the resulting file will have the correct extension but the wrong image format.

@mjauvin
Copy link
Member Author

mjauvin commented May 7, 2021

In the mean time, the following code is required:

        Event::listen('system.resizer.processResize', function ($resizer, $tempPath) {
            // Get the resizing configuration
            $config = $resizer->getConfig();
            $options = array_get($config, 'options', []);

            list($base, $ext) = explode('.', $tempPath);
            $newPath = $base . '.' . array_get($options, 'extension', $ext);

            // Resize the image
            $resizedImageContents = \Winter\Storm\Database\Attach\Resizer::open($tempPath)
                ->resize($config['width'], $config['height'], $options)
                ->save($newPath);

            if ($newPath != $tempPath) {
                File::move($newPath, $tempPath);
            }
            
            // Prevent any other resizing replacer logic from running
            return true;
        });

@bennothommo bennothommo removed this from the v1.1.4 milestone May 21, 2021
@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@github-actions
Copy link

This pull request will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this is still being worked on, please respond and we will re-open this pull request.
If this pull request is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@mjauvin
Copy link
Member Author

mjauvin commented Mar 4, 2022

Any concerns for merging this @LukeTowers?

@mjauvin
Copy link
Member Author

mjauvin commented Mar 4, 2022

Closed in favor of #74

@mjauvin mjauvin closed this Mar 4, 2022
LukeTowers pushed a commit that referenced this pull request Jul 27, 2022
This is required to allow converting images to other formats (e.g. webp). Otherwise the resulting file will have the correct extension but the wrong image format.

Fixes #9 & #74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants