emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Displaying inline svg images
Date: Wed, 9 Jan 2019 00:25:23 -0500	[thread overview]
Message-ID: <CAFyQvY23SYwyOzqehyKVoP4zaLWz77b3U1eBn+eO-Q+P7OOYew@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2365 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3749 bytes --]

             reply	other threads:[~2019-01-09  5:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09  5:25 Kaushal Modi [this message]
2019-01-09  6:46 ` Displaying inline svg images Eric S Fraga
2019-01-09  8:17   ` Colin Baxter
2019-01-09 11:53     ` Kaushal Modi
2019-01-09 12:06       ` Colin Baxter
2019-01-09 13:56       ` Eric S Fraga
2019-01-09 16:16         ` Kaushal Modi
2019-01-09 16:42           ` Eric S Fraga
2019-01-09 17:12           ` Colin Baxter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY23SYwyOzqehyKVoP4zaLWz77b3U1eBn+eO-Q+P7OOYew@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).