1

I try below code in ubuntu 22.04 but the output image resolution very low:

#+HEADER: :file /media/sf_work/demo.jpg 
#+HEADER: :results file graphics
#+HEADER: :headers '("\\usepackage{tikz}") 
#+HEADER: :fit yes :imagemagick yes :imoutoptions -geometry 800 :iminoptions -density 300 :iminoptions -background white :iminoptions -alpha remove
#+begin_src latex
\begin{tikzpicture}[scale=5]
  \draw node[circle, draw] (a) {$a$}
        node[circle, draw, right of = a] (b) {$b$}
        node[circle, draw, below of = a] (c) {$c$}
        node[circle, draw, below of = b] (d) {$d$};
\end{tikzpicture}
#+end_src

Output:

enter image description here

1 Answer 1

1

Try the following:

#+HEADER: :fit yes :imagemagick yes :imoutoptions -geometry 800 :iminoptions -density 300 -background white -alpha remove

If you have multiple :iminoptions, the last one wins and the earlier ones are ignored. You need to combine them in a single :iminoptions header.

You can check what the src block will see using the function org-babel-get-src-block-info. This is not a command, so you cannot run it with M-x ..., you need to say M-: (org-babel-get-src-block-info). It's also not documented in the manual, so it is somewhat hidden, but it is a valuable diagnostic aid, so it's worth remembering.

When you run it with your original three setting for :iminoptions it says (I've reformatted the output a bit to make it easier to read):

("latex" "\\begin{tikzpicture}[scale=5]
  \\draw node[circle, draw] (a) {$a$}
        node[circle, draw, right of = a] (b) {$b$}
        node[circle, draw, below of = a] (c) {$c$}
        node[circle, draw, below of = b] (d) {$d$};
\\end{tikzpicture}" 
((:colname-names) (:rowname-names) (:result-params "graphics" "file" "replace") 
(:result-type . value) (:results . "graphics file replace") (:exports . "results") 
(:file . "/tmp/demo.jpg") (:headers "\\usepackage{tikz}") 
(:iminoptions . "-alpha remove") 
(:imoutoptions . "-geometry 800") 
(:imagemagick . "yes") (:fit . "yes") (:tangle . "no") 
(:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) "" nil 575 "(ref:%s)")

As you can see, the other two :iminoptions headers are not present.

If you run it with the modified version I show above, it says:

...
(:iminoptions . "-density 300 -background white -alpha remove")
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.