Conversation
| * processor after applying image manipulations | ||
| * @returns {Buffer} a GIF encoded buffer | ||
| */ | ||
| ImageHandler.prototype.processGif = function (buffer) { |
Contributor
There was a problem hiding this comment.
It seems to me like you don't need to create a wrapping Promise, since both Jimp.read and GifUtil.write return one already. Could you do:
return Jimp.read(buffer).then(image => {
// (...)
return GifUtil.write(tmpGifFile, [frame]).then(gif => {
// (...)| let tmpGifFile = `${path.join(tmpDirectory, sha1(this.parsedUrl.original.path))}.gif` | ||
|
|
||
| GifUtil.write(tmpGifFile, [frame]).then(gif => { | ||
| fs.unlinkSync(tmpGifFile) |
Contributor
There was a problem hiding this comment.
I would make this async, if possible. If you want to make it use Promises without any extra work, you could replace fs with fs-extra and do:
return fs.unlink(tmpGifFile).then()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR gives CDN basic GIF support, which we lost in the switch of image processor.
It uses Jimp to load the final output buffer from Sharp, and uses https://github.com/jtlapp/gifwrap to generate a GIF frame and finally do the encoding before returning the buffer to the consumer.
No configurable image parameters have been taken into account, such as options for dithering, colour quantize method, etc.
Issue #257 suggests additional requirements such as cropping an animated GIF and selecting a poster frame. Requirements for these should be written up as new tickets, and perhaps implemented as plugins cc @abovedave @adamkdean
Close #257