emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* computing the size of a tikz to png image during export
@ 2018-01-24  7:54 Alan Schmitt
  2018-01-25  6:46 ` Eric S Fraga
  2018-01-28 15:37 ` Fabrice Popineau
  0 siblings, 2 replies; 6+ messages in thread
From: Alan Schmitt @ 2018-01-24  7:54 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello,

I use this great trick to have both a pdf and html export of tikz
images:

#+header: :file (by-backend (latex "tp6-tree.tikz") (t "tp6-tree.png"))
#+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 800
#+header: :results file raw
#+header: :fit yes
#+header: :headers '("\\usepackage{tikz}")
#+begin_src latex
\begin{tikzpicture}
…
\end{tikzpicture}
#+end_src

If I understand how it works in the png case, a standalone latex file is
first generated, then it is compiled to pdf and converted to png using
imagemagick. Instead of specifying the geometry of the image (width of
800 pixels above), I would like to compute it using its original size.
Is it possible?

Thanks a lot,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-12: 406.82, 2016-12: 404.42

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* Re: computing the size of a tikz to png image during export
  2018-01-24  7:54 computing the size of a tikz to png image during export Alan Schmitt
@ 2018-01-25  6:46 ` Eric S Fraga
  2018-01-25 17:15   ` Alan Schmitt
  2018-01-28 15:37 ` Fabrice Popineau
  1 sibling, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2018-01-25  6:46 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

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

On Wednesday, 24 Jan 2018 at 08:54, Alan Schmitt wrote:
> If I understand how it works in the png case, a standalone latex file is
> first generated, then it is compiled to pdf and converted to png using
> imagemagick. Instead of specifying the geometry of the image (width of
> 800 pixels above), I would like to compute it using its original size.
> Is it possible?

Have you tried removing the -geometry setting?  Imagemagick should be
fine with just the density option.
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-39-gc82c21

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: computing the size of a tikz to png image during export
  2018-01-25  6:46 ` Eric S Fraga
@ 2018-01-25 17:15   ` Alan Schmitt
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Schmitt @ 2018-01-25 17:15 UTC (permalink / raw)
  To: emacs-orgmode

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

On 2018-01-25 06:46, Eric S Fraga <esflists@gmail.com> writes:

> On Wednesday, 24 Jan 2018 at 08:54, Alan Schmitt wrote:
>> If I understand how it works in the png case, a standalone latex file is
>> first generated, then it is compiled to pdf and converted to png using
>> imagemagick. Instead of specifying the geometry of the image (width of
>> 800 pixels above), I would like to compute it using its original size.
>> Is it possible?
>
> Have you tried removing the -geometry setting?  Imagemagick should be
> fine with just the density option.

Thank you for the suggestion. Unfortunately the image is very large with
a density of 600, and if I use a lower density then it is too low
resolution.

I found a solution using an -resize argument. It seems to work fairly
well.

Thanks again,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-12: 406.82, 2016-12: 404.42

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* Re: computing the size of a tikz to png image during export
  2018-01-24  7:54 computing the size of a tikz to png image during export Alan Schmitt
  2018-01-25  6:46 ` Eric S Fraga
@ 2018-01-28 15:37 ` Fabrice Popineau
  2018-01-29  1:27   ` Berry, Charles
  2018-01-29 10:21   ` Alan Schmitt
  1 sibling, 2 replies; 6+ messages in thread
From: Fabrice Popineau @ 2018-01-28 15:37 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

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

2018-01-24 8:54 GMT+01:00 Alan Schmitt <alan.schmitt@polytechnique.org>:

> Hello,
>
> I use this great trick to have both a pdf and html export of tikz
> images:
>
> #+header: :file (by-backend (latex "tp6-tree.tikz") (t "tp6-tree.png"))
> #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions
> -geometry 800
> #+header: :results file raw
> #+header: :fit yes
> #+header: :headers '("\\usepackage{tikz}")
> #+begin_src latex
> \begin{tikzpicture}
> …
> \end{tikzpicture}
> #+end_src
>
>
I jump on this example to ask: does this by-backend trick still work with
Org 9.1.6?
Because I used it too and for some reason it fails to evaluate the
by-backend form now.
What am I overlooking ?

Thanks,

Fabrice

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

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

* Re: computing the size of a tikz to png image during export
  2018-01-28 15:37 ` Fabrice Popineau
@ 2018-01-29  1:27   ` Berry, Charles
  2018-01-29 10:21   ` Alan Schmitt
  1 sibling, 0 replies; 6+ messages in thread
From: Berry, Charles @ 2018-01-29  1:27 UTC (permalink / raw)
  To: fabrice.popineau@centralesupelec.fr; +Cc: Alan Schmitt, emacs-orgmode



> On Jan 28, 2018, at 7:37 AM, Fabrice Popineau <fabrice.popineau@supelec.fr> wrote:
> 
> I jump on this example to ask: does this by-backend trick still work with Org 9.1.6?

Probably not. Nowadays, you should reference `org-export-current-backend ', not `backend'.


,----[ C-h v org-export-current-backend RET ]
| org-export-current-backend is a variable defined in ‘ox.el’.
| Its value is nil
| 
| Documentation:
| Name, if any, of the back-end used during an export process.
| 
| Its value is a symbol such as ‘html’, ‘latex’, ‘ascii’, or nil if
| the back-end is anonymous (see ‘org-export-create-backend’) or if
| there is no export process in progress.
| 
| It can be used to teach Babel blocks how to act differently
| according to the back-end used.
| 
| [back]
`----

HTH,

Chuck

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

* Re: computing the size of a tikz to png image during export
  2018-01-28 15:37 ` Fabrice Popineau
  2018-01-29  1:27   ` Berry, Charles
@ 2018-01-29 10:21   ` Alan Schmitt
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Schmitt @ 2018-01-29 10:21 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: fabrice.popineau, emacs-orgmode

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

On 2018-01-28 16:37, Fabrice Popineau <fabrice.popineau@supelec.fr> writes:

> I jump on this example to ask: does this by-backend trick still work with
> Org 9.1.6?

It works here. I did not provide the definition, here it is:

(defmacro by-backend (&rest body)
  `(cl-case org-export-current-backend ,@body))

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-12: 406.82, 2016-12: 404.42

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

end of thread, other threads:[~2018-01-29 10:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24  7:54 computing the size of a tikz to png image during export Alan Schmitt
2018-01-25  6:46 ` Eric S Fraga
2018-01-25 17:15   ` Alan Schmitt
2018-01-28 15:37 ` Fabrice Popineau
2018-01-29  1:27   ` Berry, Charles
2018-01-29 10:21   ` Alan Schmitt

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).