11

I wish to display org mode inline image (in emacs) with width 400 but actually it always show it as original size.

My steps as below:

  1. Install ImageMagick with below command: sudo port install imagemagick
  2. Install emacs with below command: brew install emacs --HEAD --use-git-head --cocoa --with-gnutls --with-rsvg --with-imagemagick Then I check it, emacs version is GNU Emacs 26.0.50.1, but (image-type-available-p 'imagemagick) result is nil

  3. Edit ~/.emacs.d/init.el to add below line: (setq org-image-actual-width nil)

  4. Write below org code in test.org:

#+ATTR_ORG: :width 400 [[file:test.png]] 5. After run C-c C-x C-v,Image not displayed as 400 but actual size.

  • To install graphic Emacs (Emacs.app) with ImageMagick support via MacPorts, use sudo port install emacs-app +imagemagick. It looks you are using MacPorts to install dependency for HomeBrew, I have no idea if it should work. and there is no need to install dependency manually at all, it is your package manager's job. Besides, using two package managers at a time is usually a bad idea and unnecessary. – xuchunyang Feb 8 '17 at 17:30
  • @xuchunyang Exactly, after reinstall emacs-app with port, it works fine now. Thanks – beetlej Feb 8 '17 at 21:02
6

Imagemagick version not match.

Change brew install command as below:

brew install emacs --with-cocoa --with-gnutls --with-dbus --with-librsvg --with-imagemagick@6 --with-mailutils --devel

Then run brew info emacs to check if magicmagick is fine!

emacs: stable 25.1 (bottled), devel 25.2-rc2, HEAD
GNU Emacs text editor
https://www.gnu.org/software/emacs/
/usr/local/Cellar/emacs/25.2-rc2 (4,051 files, 120.1MB) *
  Built from source on 2017-03-11 at 16:56:47 with: --with-cocoa --with-gnutls --with-dbus --with-librsvg --with-imagemagick@6 --with-mailutils
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/emacs.rb
==> Dependencies
Build: pkg-config ✔
Optional: dbus ✔, gnutls ✔, librsvg ✔, imagemagick@6 ✔, mailutils ✔

If imagemagick@6 is checked, then everything should be fine.

In emacs, run below command to check if imagemagick package available:

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (image-type-available-p 'imagemagick)
t
ELISP>
6
(setq org-image-actual-width 400)

should do the job. The documentation of the variable (C-h v org-image-actual-width RET) gives more detail:

org-image-actual-width is a variable defined in ‘org.el’. Its value is t

Documentation: Should we use the actual width of images when inlining them?

When set to t, always use the image width.

When set to a number, use imagemagick (when available) to set the image’s width to this value.

When set to a number in a list, try to get the width from any #+ATTR.* keyword if it matches a width specification like

#+ATTR_HTML: :width 300px

and fall back on that number if none is found.

When set to nil, try to get the width from an #+ATTR.* keyword and fall back on the original width if none is found.

This requires Emacs >= 24.1, build(sic) with imagemagick support.

  • This does not sound like an answer, but could be a comment. – JeanPierre Feb 8 '17 at 17:43
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – JeanPierre Feb 8 '17 at 17:43
  • Is that better? – NickD Feb 8 '17 at 18:20
4

In your step 2,

(image-type-available-p 'imagemagick)

should return t. nil is for unavailable. Perhaps the reason you get nil is the paths from macports install of imagemagick is not being picked up by the brew install of emacs. Have you noticed any compile errors to that effect?

In any case, adjust the path to imagemagick manually or install it from brew as well. Installing both imagemagick and emacs from macports works for me.

  • Exactly, after uninstall emacs and reinstall it with port, it works fine now. – beetlej Feb 8 '17 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.