all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Displaying inline svg images
@ 2019-01-09  5:25 Kaushal Modi
  2019-01-09  6:46 ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Kaushal Modi @ 2019-01-09  5:25 UTC (permalink / raw)
  To: emacs-org list

[-- 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 --]

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  2019-01-09  5:25 Displaying inline svg images Kaushal Modi
@ 2019-01-09  6:46 ` Eric S Fraga
  2019-01-09  8:17   ` Colin Baxter
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2019-01-09  6:46 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

On Wednesday,  9 Jan 2019 at 00:25, Kaushal Modi wrote:
> Hello,
>
> I am unable to display inline SVG images.

Your example works fine for me but I am using a slightly old version of
org so maybe something has changed?

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  2019-01-09  6:46 ` Eric S Fraga
@ 2019-01-09  8:17   ` Colin Baxter
  2019-01-09 11:53     ` Kaushal Modi
  0 siblings, 1 reply; 9+ messages in thread
From: Colin Baxter @ 2019-01-09  8:17 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

>>>>> Eric S Fraga <esflists@gmail.com> writes:

    > On Wednesday,  9 Jan 2019 at 00:25, Kaushal Modi wrote:
    >> Hello,
    >> 
    >> I am unable to display inline SVG images.

    > Your example works fine for me but I am using a slightly old
    > version of org so maybe something has changed?

    > -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442


Works fine for me too and I'm using Org mode version 9.2
(release_9.2-152-gc006a6).

Best wishes,

-- 
Colin Baxter
m43cap@yandex.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Kaushal Modi @ 2019-01-09 11:53 UTC (permalink / raw)
  To: Colin Baxter, Eric S Fraga; +Cc: emacs-org list

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

>
> Thanks Eric, Colin.

Please see my further questions below.

>>>>> Eric S Fraga <esflists@gmail.com> writes:
>
>     > Your example works fine for me but I am using a slightly old
>     > version of org so maybe something has changed?
>
>     > -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442
>

I see that you are running Emacs master. Can you also report the git hash
used to build it? Also, what is your imagemagick version?

On Wed, Jan 9, 2019, 3:18 AM Colin Baxter <m43cap@yandex.com wrote:

Works fine for me too and I'm using Org mode version 9.2
> (release_9.2-152-gc006a6).
>

Great! So any regression in Org mode 9.2 is ruled out :)

I need to see what's different in my environment: Emacs version,
imagemagick version.

Later today, I'll find out my imagemagick version, and also try running my
example on Emacs 26.1.

Thanks all!

>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  2019-01-09 11:53     ` Kaushal Modi
@ 2019-01-09 12:06       ` Colin Baxter
  2019-01-09 13:56       ` Eric S Fraga
  1 sibling, 0 replies; 9+ messages in thread
From: Colin Baxter @ 2019-01-09 12:06 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list, Eric S Fraga

>>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:

--- snip ----
 
    > Great! So any regression in Org mode 9.2 is ruled out :)

    > I need to see what's different in my environment: Emacs version,
    > imagemagick version.

    > Later today, I'll find out my imagemagick version, and also try
    > running my example on Emacs 26.1.

If it helps, I tested your file using emacs-26.1 and ImageMagick 6.8.9-9.


Best wishes,

-- 
Colin Baxter
m43cap@yandex.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2019-01-09 13:56 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Colin Baxter, emacs-org list

On Wednesday,  9 Jan 2019 at 06:53, Kaushal Modi wrote:
> I see that you are running Emacs master. Can you also report the git
> hash used to build it? Also, what is your imagemagick version?

According to dpkg,

emacs-snapshot 2:20181111+emacs-26.1-3391-ga004d3bbbae-1
imagemagick    8:6.9.10.14+dfsg-7

on Debian buster/sid.

HTH
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Kaushal Modi @ 2019-01-09 16:16 UTC (permalink / raw)
  To: Kaushal Modi, Colin Baxter, emacs-org list

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

Hello Colin, Eric:

First of all, thanks for checking things on your end, and apologize for the
noise.

I had an experimental setting of image-type-header-regexps lying in my
Emacs config and that messed up the SVG inlining.

All good now.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  2019-01-09 16:16         ` Kaushal Modi
@ 2019-01-09 16:42           ` Eric S Fraga
  2019-01-09 17:12           ` Colin Baxter
  1 sibling, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2019-01-09 16:42 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Colin Baxter, emacs-org list

On Wednesday,  9 Jan 2019 at 11:16, Kaushal Modi wrote:
> First of all, thanks for checking things on your end, and apologize
> for the noise.

No worries and I'm glad you got it sorted.  These are complex systems
and hence quite fragile (unfortunately).  I spent quite some time this
morning fighting embedded calc mode in an org file and the problem was
also due to some other change I'd made...  These things happen!

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.14-1035-gfeb442

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Displaying inline svg images
  2019-01-09 16:16         ` Kaushal Modi
  2019-01-09 16:42           ` Eric S Fraga
@ 2019-01-09 17:12           ` Colin Baxter
  1 sibling, 0 replies; 9+ messages in thread
From: Colin Baxter @ 2019-01-09 17:12 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: emacs-org list

>>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:

    > Hello Colin, Eric: First of all, thanks for checking things on
    > your end, and apologize for the noise.

    > I had an experimental setting of image-type-header-regexps lying
    > in my Emacs config and that messed up the SVG inlining.

    > All good now.

No problem - I echo Eric's sentiments. We've all been there.

Best wishes,

-- 
Colin Baxter
m43cap@yandex.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-01-09 17:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-09  5:25 Displaying inline svg images Kaushal Modi
2019-01-09  6:46 ` 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.