Skip to content

fix Encode manipulator to make sure to interlace image if necessary#2

Closed
konnng-dev wants to merge 5 commits intoArt4:upgrade-to-glide-3from
Konnng:upgrade-to-glide-3
Closed

fix Encode manipulator to make sure to interlace image if necessary#2
konnng-dev wants to merge 5 commits intoArt4:upgrade-to-glide-3from
Konnng:upgrade-to-glide-3

Conversation

@konnng-dev
Copy link

@konnng-dev konnng-dev commented Jan 26, 2024

Hi @Art4 ,

I made this additional change to make sure it will create interlaced PNGS / progressive JPGS if needed.

The old strategy I made was losing the interlace information when saving the image.

Background:

Sinve intervention v3 changed strategy about encoding image, it was necessary to create a new Image instance from scratch on Glide Encode manipulator.

On https://github.com/Art4/glide/blob/upgrade-to-glide-3/src/Manipulators/Encode.php#L49-L51

return (new ImageManager($driver))->read(
            $image->encodeByExtension($format, $quality)->toString()
        );

The read method will try to read the image using several Decoders until find the best suitable for it. When it finds, it will read the image blob. But there is a catch w/ Image Magick: when it reads back image, it will scratch any interlace info if present.

Solution:

Change the interlace checking after reading the encoded image, to make sure the interlaced information will persist.

@Art4
Copy link
Owner

Art4 commented Jan 27, 2024

Thank you. Please submit your changes as a new PR in the main repository.

@Art4 Art4 closed this Jan 27, 2024
@juliovedovatto juliovedovatto deleted the upgrade-to-glide-3 branch January 30, 2024 14:29
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.

2 participants