Skip to content

Saving of resized animated GIF #3962

Answered by jcupitt
Jacherr asked this question in Q&A
May 13, 2024 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

Hi again, you need to set the new page_height so the gif saver knows how to write each page of the output image.

You don't need to chop into pages and then reassemble -- just pick a scale factor which will get the page boundaries to land in the right place. There's some sample code in the thumbnail sources:

https://github.com/libvips/libvips/blob/master/libvips/resample/thumbnail.c#L782-L791

But I'd just call thumbnail instead. It'll handle things like premultiply for you too.

VipsImage *thumb = vips_thumbnail_buffer(input_data, input_length, target_width,
    "option_string", "n=-1",
    NULL);
void *data;
size_t length;
vips_gifsave_buffer(thumb, &data, &length, NULL);

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@jcupitt
Comment options

@jcupitt
Comment options

@Jacherr
Comment options

@jcupitt
Comment options

@Jacherr
Comment options

Answer selected by Jacherr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants