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

cleanImage method bloats up animated GIF #2845

Closed
souvikdg opened this issue May 4, 2018 · 11 comments
Closed

cleanImage method bloats up animated GIF #2845

souvikdg opened this issue May 4, 2018 · 11 comments

Comments

@souvikdg
Copy link

souvikdg commented May 4, 2018

Description

We have got a highly optimised animated GIF, but the size is bloating up whenever uploaded through Craft admin panel.

Steps to reproduce

Upload this image file (670kb) through the Craft Asset Panel and the uploaded file will grow to nearly 1mb.

Additional info

  • Craft version: 2.6.3012
  • PHP version: 7.1.17
  • imagick: 3.4.3
@souvikdg
Copy link
Author

souvikdg commented May 4, 2018

Would be good to have a configuration like sanitizeSvgUploads that would skip animated GIFs from being cleansed. We had earlier faced an issue with animated GIFs (due to host constraint / old version of imagick) where the images were losing animation. Such a configuration can be handy in trusted environments.

@brandonkelly
Copy link
Member

@andris-sevcenko thoughts?

@andris-sevcenko
Copy link
Contributor

@brandonkelly If the setting by default sanitizes GIFs and users have to explicitly turn it off (consciously disabling a security feature), I feel like it's a good idea.

@brandonkelly
Copy link
Member

Should it just be GIFs, or maybe a way to disable all image sanitization (at least when uploaded via the Control Panel)?

@andris-sevcenko
Copy link
Contributor

Even though GIF gets hit the hardest, probably should stick to one setting for all sanitization - too granular config settings often get confusing.

@souvikdg
Copy link
Author

souvikdg commented May 6, 2018

The two possible aspects are the image formats and upload sources (Control Panel or site front-end). You could provide two different settings for the two aspects, but I think it would be wise to lift the security feature for Control Panel uploads only. As far as image formats go, instead of a blanket disable, one approach could be to accept a list of formats/types/extensions that will be skipped.

@brandonkelly
Copy link
Member

Agree with all of that @souvikdg. Maybe we could even roll SVGs into this, and deprecate the sanitizeSvgs config setting.

@andris-sevcenko
Copy link
Contributor

Love this.

andris-sevcenko added a commit that referenced this issue May 10, 2018
Added `transformGifs` config setting, Fixes #2845
@brandonkelly
Copy link
Member

@souvikdg One Config Setting to Rule Them All ended up not being as simple of a solution as we thought it would, so we’re going with a transformGifs config setting instead, which will disable all gif transforms – which will have the additional benifit of giving servers without ImageMagick a way of supporting animated gifs.

Already implemented in Craft 3, and we will also port it to Craft 2.

@carlcs
Copy link
Contributor

carlcs commented Jan 3, 2019

It seems like there’s quite many people wanting to have this config setting for other image formats as well. See #3287 #3060

As a workaround I override the Images service, but would love to see a config option.

<?php

namespace modules\craft;

class Images extends \craft\services\Images {

    /**
     * @inheritdoc
     */
    public function cleanImage(string $filePath)
    {
        // no cleansing
    }
}

@brandonkelly
Copy link
Member

@carlcs Let’s move the discussion over to #3287

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

No branches or pull requests

4 participants