libvips / libvips/ruby-vips

Thumbnail gif file with `crop: :centre` always creates 1 scene gif

Open
#344 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked-upstream bug
Dominant language
Ruby
Stars
904
Forks
64
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Vips::Image.thumbnail("filename.gif[n=-1]", 200, height: 200, crop: :centre) with animated GIF file saves static file with 1 scene only.

Without crop: :centre it saves animated file correctly

I used file https://i.pinimg.com/originals/96/50/f0/9650f01cd3334952b075f8cf55bedd60.gif for testing

To Reproduce
Steps to reproduce the behavior:
Run ruby script

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "ruby-vips"
  gem 'down'
end

GLib::logger.level = Logger::DEBUG

tempfile = Down.download("https://i.pinimg.com/originals/96/50/f0/9650f01cd3334952b075f8cf55bedd60.gif")

resized_image = Vips::Image.thumbnail("#{tempfile.path}[n=-1]", 400, height: 400, crop: :centre)
resized_image.write_to_file "/tmp/rabbit-with-crop.gif"
`browse /tmp/rabbit-with-crop.gif`

Expected behavior
File must be animated with all scenes cropped

Additional context
I have libvips 8.13rc1 compiled with cgif

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Ruby reproduction with the linked GIF and compare output with and without crop: :centre. Trace the thumbnail and GIF-writing path used by Vips::Image.thumbnail; done means the cropped output remains animated and contains all scenes.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.