Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

Fast gif resize #8

Open
pkieltyka opened this issue Oct 27, 2015 · 2 comments
Open

Fast gif resize #8

pkieltyka opened this issue Oct 27, 2015 · 2 comments
Assignees

Comments

@pkieltyka
Copy link
Contributor

imgry/imagick/imagick.go

Lines 195 to 199 in f7a2a8c

// TODO: instead of Coalesce, better to change the offsets.
// This is required for animated image resizing
if !sz.Flatten && i.mw.GetNumberImages() > 1 {
i.mw = i.mw.CoalesceImages()
}

@pkieltyka
Copy link
Contributor Author

The current imagick implementation for gif resizing will flatten each layer, which creates a larger in filesize image, and is MUCH slower to resize because it effectively resizes more bytes per frame to generate the image.

For example: http://imgry.pressly.com/test/fetch?url=http%3A%2F%2Fwww.thisiscolossal.com%2Fwp-content%2Fuploads%2F2015%2F04%2Fcine-1.gif&size=800x

this will load quickly because its already sized/cached -- but, try to change the size query param to 840x or 730x .. pick something ... it will take over 2 seconds. And compare the filesize to the original image url: http://www.thisiscolossal.com/wp-content/uploads/2015/04/cine-1.gif

if you open the gif in an image editor, you will see the layers (frames), the subsequent frames are actually offset positions, layered on top of eachother. Other gifs do use full frames and a 0,0 offset.

The goal is to not have to flatten each frame, and try to keep the frames intact, and resize the respective layers etc. to get the final image.

@xiam
Copy link
Contributor

xiam commented Nov 19, 2015

Closed by #9?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants