Skip to content

Editing gif frames with Jimp -> The value of "offset" is out of range #24

@ghost

Description

Using this gif with the code below https://media1.giphy.com/media/HnKSuvC39SdOM/source.gif

I am getting this error on GifUtil.write():

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 43818. Received 43820

Is this a bug or am I doing something wrong? I'm trying to downsize the gif to 160x160px.

var filePath = "pathtofile.gif"

await GifUtil.read(filePath)
.then(async inputGif => {
	//Loop through each frame
	for (var i=0; i<inputGif.frames.length; i++){
		//Modify the frame image buffer with jimp
		var newImgBuffer = await GifUtil.copyAsJimp(jimp, inputGif.frames[i])
		.resize(160, 160) // resize
		.getBufferAsync(jimp.AUTO)

		inputGif.frames[i].bitmap.height = 160
		inputGif.frames[i].bitmap.width = 160
		inputGif.frames[i].bitmap.data = newImgBuffer
	}
	
	//Pass inputGif to write() to preserve the original GIF's specs.
	return GifUtil.write(filePath, inputGif.frames, inputGif)
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions