emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Displaying inline svg images


From: Kaushal Modi
Subject: [O] Displaying inline svg images
Date: Wed, 9 Jan 2019 00:25:23 -0500

Hello,

I am unable to display inline SVG images.

Here is the minimum reproducible example:

1. I have org-image-actual-width defcustom at its default value of t.
2. Here is the Org file:

=====
#+startup: inlineimages

[[file:red-blue-squares.svg]]
=====

3. Here is the example SVG file. Put it in the same dir as the Org file as red-blue-squares.svg.

=====
<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
 width="467" height="462">
  <rect x="80" y="60" width="250" height="250" rx="20"
      style="fill:#ff0000; stroke:#000000;stroke-width:2px;" />

  <rect x="140" y="120" width="250" height="250" rx="40"
      style="fill:#0000ff; stroke:#000000; stroke-width:2px;
      fill-opacity:0.7;" />
</svg>
=====

Upon saving the .svg file and then opening the .org file, I do not see the image inlined.

Is anyone able to reproduce this?

Upon investigating the org-display-inline-images function in org.el, I found that this happens because the internal variable width is evaluated as nil and `:width nil' gets passed to the `create-image' function .. resulting in a zero-width SVG.

Though, this is not a problem with PNG and JPG images.

As a quick workaround, I did this:

=====
diff --git a/lisp/org.el b/lisp/org.el
index ea1607d85..54e8d0142 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18618,7 +18618,8 @@ boundaries."
              (let ((image (create-image file
                         (and width 'imagemagick)
                         nil
-                        :width width)))
+                        ;; :width width
+                        )))
                (when image
              (let ((ov (make-overlay
                     (org-element-property :begin link)
=====

i.e. I stopped passing the :width property to create-image altogether and after that the SVG image showed inline just fine.

So, is there any point passing `:width width' if width is nil? If not, I can work on a patch that prevents passing that property only in that case.



Org version: Org mode version 9.2 (release_9.2-151-g8a5d8f ..) | master branch
Emacs version: GNU Emacs 27.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version 2.24.23)
 of 2019-01-08, built using commit 55c5e26307a1e8f1fff74415fc560aa172a421cf | master branch


--
Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]