How do I resize an animated GIF using nearest-neighbor interpolation?

6

I'd like to resize an animated GIF image of some pixel art.

I'm on macOS and am comfortable with the command-line.

Tim Swast

Posted 2017-03-23T19:44:44.980

Reputation: 241

1

Is this question about resizing an animated GIF or just a plain/static GIF image? Also, this might also be doable via ImageMagick.

– JakeGould – 2017-03-23T20:06:09.507

1Animated GIF. I'll update the question. – Tim Swast – 2017-03-24T03:08:50.147

Answers

8

I used Gifsicle to do this. You can install it with homebrew.

brew install gifsicle

Then, to resize an image using nearest-neighbor interpolation, run

gifsicle --resize 512x512 --resize-method sample doodle002.gif > doodle002-big.gif

From the manual for the --resize-method parameter:

The ‘sample’ method is a point sampler. Each pixel position in the output image maps to exactly one pixel position in the input, so when shrinking, full rows and columns from the input are dropped.

Even though this doesn't explicitly say "nearest-neighbor interpolation" the described method sounds exactly like nearest-neighbor.

Tim Swast

Posted 2017-03-23T19:44:44.980

Reputation: 241

oop, typo in gifscicle for the copy-pasters out there – andrewxhill – 2018-08-20T15:33:21.347

@andrewxhill Thanks! I've updated the brew command. – Tim Swast – 2018-08-21T04:25:13.140