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

Enhancement: improve animated/multipage image resizing #2275

Closed
lovell opened this issue Jun 30, 2020 · 9 comments
Closed

Enhancement: improve animated/multipage image resizing #2275

lovell opened this issue Jun 30, 2020 · 9 comments

Comments

@lovell
Copy link
Owner

lovell commented Jun 30, 2020

Given Safari will soon be supporting WebP, I suspect a shift away from the use of animated GIF images towards the use of animated WebP images, which are significantly more efficient, is coming.

Operations like extract and rotate on individual pages/frames might be rather complex, but a possible new resizePages operation to resize all pages/frames in an image to a given width or height (these would have to be mutually exclusive, plus an optional kernel), would be relatively straightforward.

Update: this has been implement via #2789, which sets page heights automatically using the existing resize API.

@lovell lovell changed the title Enhancement: improve handling (when resizing) of animated/multipage images Enhancement: improve animated/multipage image resizing Jul 1, 2020
@OJezu
Copy link

OJezu commented Jul 6, 2020

Why not load all pages by default, though? Is BC the only concern? I guess it can break "convert first frame of gif/tiff to jpeg" scenario.

@tpetry
Copy link

tpetry commented Aug 31, 2020

Why not simply apply all operations on all frames? I would need compositing functionality for animated gifs. Duplicating every method to apply for all frames would be a rather complex task.
It would be easier applying all operations on all frames and the ability to extract single frames or sequences and construct new animated images based on frames/sequences. So compositing images on a subset on frames can be implemented based on these primitives.

@Dramex

This comment has been minimized.

@Alex--wu

This comment has been minimized.

@salipitchero
Copy link

Hi,

was a decision ever made on this enhancement? A resize function for multiple frames would be really useful. Failing that, is it possible to do with the current sharp API, and could some docs be added instead for the mean time?

Thanks

@lovell
Copy link
Owner Author

lovell commented Aug 26, 2021

The future possible enhancement in PR #2789 may remove the need to provide pageHeight.

@wchaws
Copy link

wchaws commented Nov 27, 2021

Hi, @lovell

How about expose arrayjoin API in sharp to support animated/multipage image resizing? I found a sample code at libvips/libvips#1167 (comment). It's quite simple. The only missing API is arrayjoin. I found this API is already existing in sharp source code.

VImage VImage::arrayjoin( std::vector<VImage> in, VOption *options )

PROPOSED API

sharp.arrayjoin([img0, img1, img2, ...], {})

@lovell
Copy link
Owner Author

lovell commented Nov 27, 2021

@wchaws Please see #1580

@lovell lovell added this to the v0.30.0 milestone Dec 11, 2021
@lovell
Copy link
Owner Author

lovell commented Feb 1, 2022

This oft requested feature is now available in v0.30.0 - enjoy!

Thanks again, as always, to @kleisauke for doing the work to implement it.

@lovell lovell closed this as completed Feb 1, 2022
eit added a commit to eit/serverless-image-handler that referenced this issue Mar 7, 2022
Update sharp version to support animated image resizing
You can also take a look here. lovell/sharp#2275
eit added a commit to eit/serverless-image-handler that referenced this issue Mar 7, 2022
Update sharp version to support animated image resizing
You can also take a look here. lovell/sharp#2275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants