nodebb-plugin-imagemagick installed an enabled, but GIFs still don't work
-
Hi,
I'm trying to enable animated GIFs on my NodeBB. I installed and enabled the Image Magick extension: https://github.com/NodeBB/nodebb-plugin-imagemagick
Then Rebuilt&Restarted
It says:
"Why replace?
NodeBB uses a js-only alternative, which may be slower, or less featureful. Additionally, animated gifs are supported with ImageMagick, while they are not supported in the bundled version.Requirements
NodeBB v1.0.0 or a suitably recent version
Setup
None, just install and activate."But I'm unable to upload GIFs still.
-
Look at the only open issue: https://github.com/NodeBB/nodebb-plugin-imagemagick/issues/7
It doesn't work anymore and didn't for more than a year
-
And a little more context than "cropper broke it":
The NodeBB gets image from cropperjs using
cropper.getCroppedCanvas()
. This utilizesCanvasRenderingContext2D.drawImage()
- and this doesn't support animated files. Depending on the browser that means the cropper will send only the first or the last frame of the gif.There is a way to overcome this problem, but it adds complexity and requires additional dependencies. Basically, the cropper has to have a fallback for animated images, where if one is detected instead of
cropper.getCroppedCanvas()
onlycroppper.getData()
is used and the data from it along with the original animated image is passed to another (probably back-end) software that works with gifs - for example ImageMagick.So the problem with this plugin is in the front-end and a fix would require some changes to how cropper works in core NodeBB.
-
I doubt it, as repairing it would require either:
- disabling the cropper
- modifying core NodeBB
- somehow bypassing the cropper with a client-side script
Option 2 sounds like the best, but it will require some work and take some time probably (not just to add it to NodeBB, but also time waiting for next release). I think the best way to do it would be to add a fallback for gifs (that is - with animated gifs js will send the unmodified image and data from cropper, so backend can work with it) and a filter hook that fires after that fallback.
Then NodeBB wouldn't need another dependency and you could choose what to use for parsing gifs.But again - that requires some work and time, and I don't think it's really a priority for NodeBB team so someone from the community would have to contribute
-
@oplik0 You're correct, of course, the image processor we use, jimp, does not support GIFs. Skipping the cropper on a gif would be doable, I think...
Skip cropper/resizer on gifs 路 Issue #7920 路 NodeBB/NodeBB
Unless there are security issues I am unaware of, it is probably okay to skip the cropper directly when uploading a GIF for use as an avatar, etc. The downside, of course, is that you might have a massive gif 馃槙 But since jimp doesn't sup...
GitHub (github.com)
-
Good news guys, GIFs are back!!! https://github.com/NodeBB/NodeBB/commit/9a7560049a33e7586faa14942c06c0705d06ce6f
Make sure you have nodebb-plugin-imagemagick installed on your NodeBB. Imagemagick also needs to be installed on your server.