From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pip Cet Subject: Re: Inline Images Export Bug Date: Wed, 26 Aug 2015 22:40:29 +0000 Message-ID: References: <55DDFCBF.2050202@gmail.com> <876141apq4.fsf@gmx.us> <87egip1zoe.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b10c8899c6f8a051e3e8954 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUjMt-00056n-6l for emacs-orgmode@gnu.org; Wed, 26 Aug 2015 18:40:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUjMr-00052N-S2 for emacs-orgmode@gnu.org; Wed, 26 Aug 2015 18:40:31 -0400 Received: from mail-ig0-x234.google.com ([2607:f8b0:4001:c05::234]:34088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUjMr-00052F-GC for emacs-orgmode@gnu.org; Wed, 26 Aug 2015 18:40:29 -0400 Received: by igui7 with SMTP id i7so48838170igu.1 for ; Wed, 26 Aug 2015 15:40:29 -0700 (PDT) In-Reply-To: <87egip1zoe.fsf@gmx.us> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rasmus Cc: emacs-orgmode@gnu.org --047d7b10c8899c6f8a051e3e8954 Content-Type: text/plain; charset=UTF-8 Okay, I just checked (sorry, had to regenerate the files and that took some time), and with the current version of Firefox the code I pasted is unnecessary. The problem I had with previous Firefox versions is that those decided on a scale for displaying the SVG that differed from its preferred resolution, but only if an object tag was used for inclusion; img tags would use the preferred resolution and everything was fine. The reason for the pt-to-px arithmetic is that graphviz outputs (or used to) SVGs with a preferred size specified in pt only, not in px. I'm not sure, but I think HTML pt and SVG pt don't necessarily agree. Org mode is generating this tag: Sorry, your browser does not support SVG. Which looks okay to me. It's browser support that's the issue. > The problems with the second bit of exported code is that it doesn't scale the image to fit the block with 50% width (only a small part of the image is visible) Is it possible you're using an old browser? I'm on Iceweasel (Firefox) 38.1.0. (The bug was there a year or two ago, so by my standards it's a recent fix that we shouldn't rely on yet.) > and you when you right click on the image, you can't view it, save it or anything. Again, I can, using the "This Frame" popup menu. But clearly that menu name is misleading and confusing in this case! And I think that is reason enough to stick with the img tag for now: Firefox users can't save the image unless they telepathically know that "frame" means "image". "This Object" might be okay, I guess. My suggestion is to use img for images; that also appears to be the consensus on Stack Overflow. Let's find a good syntax for including interactive objects in Org mode, though. On Wed, Aug 26, 2015 at 9:56 PM, Rasmus wrote: > Hi, > > Pip Cet writes: > > > let found = false; > > for (let el of svgdoc.getElementsByTagName("svg")) { > > let width = el.getAttribute("width"); > > let height = el.getAttribute("height"); > > > > let width_pt = width.match(/^([0-9]*)pt$/)[1]; > > let height_pt = height.match(/^([0-9]*)pt$/)[1]; > > > > let width_px = 5/4 * width_pt; > > let height_px = 5/4 * height_pt; > > > > object.setAttribute("width", width_px + "px"); > > object.setAttribute("height", height_px + "px"); > > found = true; > > So are you saying that Org is changing the size from px to pt? Can you > try to explain the problem you observe in words? > > Thanks, > Rasmus > > -- > The second rule of Fight Club is: You do not talk about Fight Club > --047d7b10c8899c6f8a051e3e8954 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Okay, I just checked (sorry, had to regenerate t= he files and that took some time), and with the current version of Firefox = the code I pasted is unnecessary.

The problem I had with previ= ous Firefox versions is that those decided on a scale for displaying the SV= G that differed from its preferred resolution, but only if an object tag wa= s used for inclusion; img tags would use the preferred resolution and every= thing was fine.

The reason for the pt-to-px arithmetic is that= graphviz outputs (or used to) SVGs with a preferred size specified in pt o= nly, not in px. I'm not sure, but I think HTML pt and SVG pt don't = necessarily agree.

Org mode is generating this tag:
<object type=3D"image/svg+xml" data=3D"org/op-prec.= svg" >
Sorry, your browser does not support SVG.</object><= br>
Which looks okay to me. It's browser support that'= ;s the issue.

> The problems with the second bit of exported code= is that it doesn't=20 scale the image to fit the block with 50% width (only a small part of=20 the image is visible)

Is it possible you're using an = old browser? I'm on Iceweasel (Firefox) 38.1.0. (The bug was there a ye= ar or two ago, so by my standards it's a recent fix that we shouldn'= ;t rely on yet.)

> and you when you right click on the image, you= =20 can't view it, save it or anything.

Again, I can, usi= ng the "This Frame" popup menu.

But clearly that menu name= is misleading and confusing in this case! And I think that is reason enoug= h to stick with the img tag for now: Firefox users can't save the image= unless they telepathically know that "frame" means "image&q= uot;. "This Object" might be okay, I guess.

My = suggestion is to use img for images; that also appears to be the consensus = on Stack Overflow. Let's find a good syntax for including interactive o= bjects in Org mode, though.

On Wed, Aug 26, 2015 at 9:56 PM, Rasm= us <rasmus@gmx.us> wrote:
Hi,<= br>
Pip Cet <pipcet@gmail.com> wr= ites:

>=C2=A0 =C2=A0 =C2=A0let found =3D false;
>=C2=A0 =C2=A0 =C2=A0for (let el of svgdoc.getElementsByTagName("sv= g")) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let width =3D el.getAttribute("w= idth");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let height =3D el.getAttribute("= height");
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let width_pt =3D width.match(/^([0-9]= *)pt$/)[1];
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let height_pt =3D height.match(/^([0-= 9]*)pt$/)[1];
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let width_px =3D 5/4 * width_pt;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0let height_px =3D 5/4 * height_pt; >
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0object.setAttribute("width"= , width_px + "px");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0object.setAttribute("height"= ;, height_px + "px");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0found =3D true;

So are you saying that Org is changing the size from px to pt?=C2=A0= Can you
try to explain the problem you observe in words?

Thanks,
Rasmus

--
The second rule of Fight Club is: You do not talk about Fight Club

--047d7b10c8899c6f8a051e3e8954--