10

I am trying to display images in org files. I have used links such as

[[file:~/path/to/image.png]]

When I click on the link, it gives me another buffer in which there are only symbols. When I put the cursor on the link and type C-c C-x C-v, there is an error message in the minibuffer saying

No images to display inline

I tried to enable iimage-mode but it didn't work either. So, I wonder if there is a problem with the org version installed with Emacs (I am using Emacs 24.4 with Org 8.2.10 and I am on Windows) or is there any configuration that I should do?

aymenbh
  • 101
  • 1
  • 4
  • Have you tested this with, say, a jpg image? Sometimes png support is a little fiddly. – Matthew Piziak Mar 18 '15 at 18:45
  • Works fine for me.. I started an `emacs -Q` session, `M-x org-mode`, `[[file:~/path/to/image.png]]` (with path pointing to an actual .png) and `C-c C-x C-v`. I am on latest emacs build from git, built with imagemagick on RHEL 5. `org-mode` is the latest available on Melpa. – Kaushal Modi Mar 18 '15 at 18:57
  • @MatthewPiziak, I just tried with a jpg image. It's the same problem. – aymenbh Mar 18 '15 at 18:59
  • @kaushalmodi, I tried the manipulation on two different computers, same result. I downloaded Emacs a few weeks ago. Which version of org-mode do you have?. – aymenbh Mar 18 '15 at 19:02
  • @aymenbh I have the org-mode version updated from Melpa 2 days ago. But I don't believe this has to do with org-mode version. This feature worked for org 7.x versions too. – Kaushal Modi Mar 18 '15 at 19:07
  • @aymenbh Can you repeat this problem in an `emacs -Q` session? – Kaushal Modi Mar 18 '15 at 19:09
  • @aymenbh While the point in on the org-link, `M-x org-display-inline-images` should work. – Kaushal Modi Mar 18 '15 at 19:13
  • @aymenbh While the point in on the org-link, M-x org-display-inline-images should work if you are not running emacs with "-nw" option. Also `M-: (image-type-available-p 'imagemagick)` evaluates to `t` for me as I have imagemagick available on my system. – Kaushal Modi Mar 18 '15 at 19:23
  • @kaushalmodi I am on Windows platform. I am not running emacs with options. I just click on the icon. Besides, I don't have imagemagick installed. Should I? – aymenbh Mar 18 '15 at 19:30
  • 1
    Windows is the key here, you don't have the necessary libraries for displaying images. I've got a couple different Emacs distros on my Windows box at the moment, and can only display pngs using the one obtained here: https://bitbucket.org/Haroogan/emacs-for-windows/ – glucas Mar 18 '15 at 19:32
  • @kaushalmodi M-x org-display-inline-images does not work either... It displays no error message though. – aymenbh Mar 18 '15 at 19:32
  • The provided answers could not help me, which is why I am documenting my problem and solution here. I made a flowchart in the png-format with latex-tikz. I then put the link to the file into my org-file as usual, but the inline-image would not display and when exporting to either html or pdf the image would also not display. Meanwhile I had several png-images displaying perfectly fine in the same buffer, which were made using matplotlib/python. What finally worked for me: 1. Convert png to pdf 2. Convert pdf tp png 3. Insert link What went wrong? I am still not sure why exactly this was happen – pana pana Oct 07 '22 at 06:27

4 Answers4

10

In addition to the above points there is one more detail. If clicking the link displays the image correctly in a new buffer, but toggling org-display-inline-images returns the message No images to display inline, you may have description text in the link: [[path_to_image][description]]. Remove the description, leaving only [[path_to_image]], and the images should display inline correctly.

As explained in the org manual:

http://orgmode.org/manual/Handling-links.html#Handling-links

C-c C-x C-v (org-toggle-inline-images) Toggle the inline display of linked images. Normally this will only inline images that have no description part in the link, i.e., images that will also be inlined during export. When called with a prefix argument, also display images that do have a link description. You can ask for inline images to be displayed at startup by configuring the variable org-startup-with-inline-images.

Does anyone know the prefix for displaying inline images that have description text?

Snelephant
  • 814
  • 1
  • 7
  • 17
4

Emacs for Windows is generally not distributed with the necessary libraries to display PNG and other image formats. See this section of the GNU Emacs FAQ for MS Windows.

The easiest solution is to install an Emacs distributions for Windows that is built with image support, such as this one.

Alternatively you can add the necessary libraries. See this question on Stack Overflow.

glucas
  • 20,175
  • 1
  • 51
  • 83
  • I just downloaded the distro. It works fine when I click on the link for jpg images but not for png images. For these, I get a small black box with white borders. But it does not work for C-x C-c C-v nor M-x org-display-inline-images. I get the same results as above. – aymenbh Mar 18 '15 at 19:55
  • Interesting, I tested it with a png file. (I had been pointed to this specific distro a while back for problems with another image format.) I may have some other libraries on the exec path or something -- I'll take a closer look. – glucas Mar 18 '15 at 21:35
  • 1
    The distribution by Vincent Goulet has the `*.dll` files needed: http://vgoulet.act.ulaval.ca/en/emacs/ "*This version of Emacs bundles the libraries needed to display images in formats XPM, PNG, JPEG, TIFF and GIF supported Windows since Emacs version 22.1. Among other things, this means that the toolbar displays in color, that the ESS toolbar displays correctly and that the preview-latex mode of AUCTeX works to its full extent. However, the latter requires to separately install Ghostscript and to make sure that the file gswin32c.exe is in a folder along the PATH environment variable.*" – lawlist Mar 19 '15 at 00:31
  • @glucas I tried it again on my computer at the office, it works just fine for both jpg and png images. I may have something missing in my other computer at home. However, it works only when I click on the org-link, not when I use C-x C-c C-v. Besides (when it works), it shows the images on a new buffer. Is there a way to show it on the same buffer as the link? – aymenbh Mar 19 '15 at 08:39
  • I made some tests to see which libraries needed to be added. Adding just libpng16-16.dll and libjpeg-8.dll from the Emacs distribution on bitbucket site (I have already zlib1) is not sufficient to have png and jpg support. However, the corresponding libraries libpng16-16.dll and libjpeg-9.dll from Vincent Goulet distribution work. – aymenbh Mar 19 '15 at 09:37
  • @aymenbh Toggling images inline with C-c C-x C-v is working for me. There is a regular expression in `org-display-inline-images` that has to match the file name, but just did a quick test with `[[file:~/foo.png]]` as well as `[[file:C:/Users/....]]` and it behaves as expected. I did somehow end up with a link like this `[[file:C:/~/foo.png]]` that did not work inline but did work clicking to open in another buffer. – glucas Mar 19 '15 at 15:24
  • 1
    This was working perfectly with Emacs 24.3. I just upgraded to Emacs 25.1 and nothing is working anymore. All the DLLs that were working with 24.3 are in `/bin/` but `(image-type-available-p 'png)` still return `nil` even if `(print image-library-alist)` shows that the right file is handled. Any ideas why this is not working anymore in Emacs 25.1? – Neoasimov Nov 07 '16 at 20:38
4

Just in case anybody had already downloaded the PNG DLL and they still get the

No images to display inline

message, [[Z:\test.png]] collapses down, but running org-toggle-inline-images does not expand it into an image. However [[file:Z:\test.png]] does. Note that the file: part is important.

BTW - I downloaded my PNG dll from https://sourceforge.net/projects/ezwinports/files/, but Vincent Goulet's distribution mentioned above seems like a good idea.

Tahir Hassan
  • 285
  • 2
  • 9
1

Based on manual, provided by Snelephant's answer If your image also contains a description on the link, then you should use:

C-u C-c C-x C-v
gekaklam
  • 111
  • 2
  • Should be a comment on the mentioned answer. perhaps it could be addressed by a moderator or expanded to be legible as an answer in its own right. – manandearth Apr 01 '19 at 16:02
  • I tried to put is as a comment, but it required that I have 50+ reputation. And I don't think that there's more to add,so to expand it more would be repeating what was already said. – gekaklam Apr 03 '19 at 11:44