emacs-circe / circe

Circe, a Client for IRC in Emacs
GNU General Public License v3.0
390 stars 51 forks source link

Makes ImageMagick image creation optional #382

Closed ghost closed 3 years ago

ghost commented 3 years ago

Recent versions of emacs no longer use ImageMagick by default to display images: https://github.com/emacs-mirror/emacs/blob/emacs-27.1/etc/NEWS#L96-L98

Consequently, some emacs binary package maintainers are compiling emacs without ImageMagick support.

For example, on Arch Linux, notice how libmagick6 is listed as a dependency of an older version of emacs: https://aur.archlinux.org/packages/emacs-24bit/

but not the latest emacs package: https://www.archlinux.org/packages/extra/x86_64/emacs/

We can even see when libmagick was removed as a dependency: https://github.com/archlinux/svntogit-packages/commit/f687dac70acd9a56279fbf0f8b34bf6a9865ba3b#diff-3e341d2d9c67be01819b25b25d5e53ea3cdf3a38d28846cda85a195eb9b7203a

This breaks circe-display-images on versions of emacs >= 27.1.

One could always download the emacs sources and compile after 'configure --with-imagemagick', at the cost of losing automatic package management.

A better solution would be to use ImageMagick only if it's available, otherwise fall back to emacs's recent default image creation mechanism: this is what this PR implements.

wasamasa commented 3 years ago

What you'll really want to do is test for scaling or ImageMagick (or give up and not scale images). Look at how shr.el does it (shr-put-image and everything it depends on).

ghost commented 3 years ago

Sorry, not sure I understand: why would I want to check for scaling?

wasamasa commented 3 years ago

It's the only way to be sure that scaling works without ImageMagick. That being said, if Emacs just ignores :max-height if scaling isn't supported, then it shouldn't make a difference with the current fallback being to not scale instead.