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

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

Closed
wants to merge 5 commits into from

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