Skip to content

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

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

mjauvin wants to merge 4 commits into
wintercms:developfrom
mjauvin:use-extension-for-type-conversion

Conversation

@mjauvin

@mjauvin mjauvin commented Mar 17, 2021

Copy link
Copy Markdown
Member

@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

mjauvin commented May 7, 2021

Copy link
Copy Markdown
Member Author

@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

mjauvin commented May 7, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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

mjauvin commented Mar 4, 2022

Copy link
Copy Markdown
Member Author

Any concerns for merging this @LukeTowers?

Comment thread src/Database/Attach/Resizer.php Resolved
@mjauvin

mjauvin commented Mar 4, 2022

Copy link
Copy Markdown
Member Author

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