Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs: providing ImageMagick support #70631

Closed
Anton-Latukha opened this issue Oct 7, 2019 · 22 comments
Closed

Emacs: providing ImageMagick support #70631

Anton-Latukha opened this issue Oct 7, 2019 · 22 comments
Labels
0.kind: bug Something is broken

Comments

@Anton-Latukha
Copy link
Contributor

Anton-Latukha commented Oct 7, 2019

Describe the bug

For support of imagemagick, which is allows a lot of picture and even gif abilities, picture previews, in Emacs - pretty handy stuff - it is needed to overload Emacs closure and as so - compile it only for enabling that.

To Reproduce

Install Emacs.

Run any imagemagic related feature.

Observe that there is no support of it.

Observed behavior

helm-M-x: Emacs with ‘imagemagick’ support is required. (libmagickcore, libmagickwand, --with-imagemagick)

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.75, NixOS, 20.03pre194293.2436c27541b (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3`
 - channels(root): `"nixos, unstable-20.03pre194293.2436c27541b"`
 - channels(pyro): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@Anton-Latukha Anton-Latukha added the 0.kind: bug Something is broken label Oct 7, 2019
@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Oct 7, 2019

I probably just wanted to analyze myself and hear the thoughts on this.

Probably I would just transform this issue into Emacs linkage issue.

Probably the right thing is to grow the Emacs closure if --with-imagemagic, but it a default case, and imagemagic closure is 630 Mb.

@Anton-Latukha Anton-Latukha changed the title How to provide a static path to the library for the application Fature request: Ability to provide a static path to the library for the application Oct 7, 2019
@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Oct 7, 2019

@matthewbauer Please say a word.

Should I include --with-imagemagic and extend Emacs with real Imagemagic support.
Since it would grow the closure, but really enable ImageMagic and extend, improve image and preview support in Emacs.

I made a diff between nix-store closures.

In common they would deduplicate:

cairo
fontconfig
freetype
gdk
glib
glibc
libICE
libjpeg
libpng
librsvg
libSM
libtiff
libX11
libXext
libxml2
zlib

And list of what is new to Emacs closure from ImageMagic:

bzip2
coreutils
djvulibre
fftw
gcc
ilmbase
imagemagick
lcms2
libde265
libwebp
libXt
openexr
openjpeg
xz

(also why is gcc there, probably should be looked into)

It seems like it would add ~50-150 MB.

What you would say, powerful by default (include in withX), or customizable (withImageMagic).

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Oct 7, 2019

About GCC in ImageMagic created a report: #70647, it would be solved in time.

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Oct 8, 2019

@jwiegley Good day, John.

Sorry to bother you, you are the maintainer that was last active regarding Emacs.

What do you think about the two messages above: #70631 (comment)

@jwiegley
Copy link
Contributor

jwiegley commented Oct 8, 2019

I would like to see ImageMagick support included. And on both Darwin (which does not use X) and Linux.

@matthewbauer matthewbauer changed the title Fature request: Ability to provide a static path to the library for the application Feature request: Ability to provide a static path to the library for the application Oct 8, 2019
@matthewbauer
Copy link
Member

So I suspect the issue is that "shrink-rpath" is removing imagemagick from the RPATH. A quick fix is to add "dontPatchELF" to the Emacs derivation. PatchELF should skip anything that has the DT_NEEDED flag set. Something must be off with ImageMagick that it doesn't get that flag.

One trick you can do to add imagemagick without recompiling is by setting LD_LIBRARY_PATH to the imagemagick directory. Something like LD_LIBRARY_PATH=$(nix-build '<nixpkgs>' -A imagemagick)/lib. I've wondered if setting LD_LIBRARY_PATH=/run/current-system/sw/lib globally would be a good idea? It would probably be controversial and result in bad contamination though.

@Anton-Latukha Anton-Latukha changed the title Feature request: Ability to provide a static path to the library for the application Emacs: providing ImageMagick support Oct 8, 2019
@Anton-Latukha
Copy link
Contributor Author

Ok. I decided that raising lib question is a very dead horse topic. I also contradicted myself there, I've seen imagemagick already a build-dep in code, and wrote description thinking its support is already enabled, but there is no --with-imagemagick set in code, so I do not know why it is done so.

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Oct 8, 2019

@jwiegley @matthewbauer
I rewrote & downscaled the issue to Emacs stuff.

I'm doing imagemagick because the man did a Telegram client in Emacs: https://github.com/zevlg/telega.el, which is, funny enough, objectively superior to all other Telegram desktop clients includding official app and Web service app, superior by implemented Telegram features.

Mainly I just want to be able to message people without waking them up. But that it is in Emacs is a bonus.

@cab404
Copy link
Member

cab404 commented Jan 1, 2020

It looks like this can be closed safely, there's

pkgs.emacs.override { imagemagick = pkgs.imagemagickBig; }

which adds imagemagick support (at least it works for telega). @Anton-Latukha, can you try it?

@costrouc
Copy link
Member

costrouc commented Jan 2, 2020

@cab404 this works for me. I was using home manager and set program.emacs.package = pkgs.emacs.override { imagemagick = pkgs.imagemagickBig; }.

To easily check if this worked the following elisp should return t

(image-type-available-p 'imagemagick)

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Apr 19, 2020

@cab404

You mentioned, "at least it works for telega".

'cuz I tried some time ago, telega server failed to build on NixOS. As an example, telega upstream doc mentions:

It will install headers to /usr/local/include and library itself into /usr/local/lib. These paths are hardcoded in telega.el.

AFAIR that is not the only hardcode place.

Upstream things are so upstream.

Is it working for you on NixOS and how you achieved it?

@cab404
Copy link
Member

cab404 commented Apr 19, 2020

@Anton-Latukha

Is it working for you on NixOS and how you achieved it?

https://gitlab.com/cab404/nixos-config/-/blob/a7eaa0990fa9f1cda1e383ef2d01403a2b2aaf26/home.nix

telega changes: 13, 61, 260
It's pretty much the same in system config

@Anton-Latukha
Copy link
Contributor Author

@cab404

Aha.

Thanks.

@cab404
Copy link
Member

cab404 commented Apr 20, 2020

@cab404

Aha.

Thanks.

So, that worked?

@Anton-Latukha
Copy link
Contributor Author

Anton-Latukha commented Apr 20, 2020

@cab404

Kind of...

Telega starts to intialize. But fails with error code:

error in process filter: telega--authorization-ready: TDLib version=1.5.0 < 1.6.0 (min required), please upgrade TDLib and recompile ‘telega-server’
error in process filter: TDLib version=1.5.0 < 1.6.0 (min required), please upgrade TDLib and recompile ‘telega-server’

I'm sitting on the current nixos-unstable and current TDLib is 1.6.0.

So it seems state in the link you provided needs additionally an old TDLib.

I would try up-to-date emacsPackages.telega, as you did now. I was puzzled before, and now I now know that Emacs uses both own package repo as also Emacs packages installed through NixOS. I've seen today that NixOS Emacs in package-directory-list from the get-go already provides a proper NixOS path to find provided Emacs NixPkgs.

...

Yep, it works.

@moritzschaefer
Copy link
Contributor

This issue is also affecting emacs when using EXWM. I added a PR that fixes this and am happy for contributions (@exwm-people)

@tazjin
Copy link
Member

tazjin commented Aug 4, 2020

@moritzschaefer Does that actually solve the problem for you?

I use EXWM (but not through the module) and haven't been able to get my Emacs to reliably build with ImageMagick support at all.

@moritzschaefer
Copy link
Contributor

moritzschaefer commented Aug 4, 2020

@tazjin The code from the PR above #94648 does work for me (I can zoom in images in emacs and it doesnt complain about missing imagemagick-support anymore)

@stale
Copy link

stale bot commented Feb 2, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 2, 2021
@adisbladis
Copy link
Member

This issue is also affecting emacs when using EXWM.

How is this affecting exwm in any way?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 25, 2021
@moritzschaefer
Copy link
Contributor

@adisbladis When working with image-buffer (e.g. zooming).

@adisbladis
Copy link
Member

Since it's disabled by default upstream and emacs.override { withImageMagick = true; } now works ( fixed in #114348 ) I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants