Lower half of tikzcd images truncated by convert

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ksb
Posts: 3
Joined: 2019-06-12T00:52:42-07:00
Authentication code: 1152

Lower half of tikzcd images truncated by convert

Post by ksb » 2019-06-12T01:22:18-07:00

Hi, I have many small LaTeX diagrams which I can accurately convert to .ps files (an example below)

Code: Select all

\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{amsmath}\usepackage{mathtools}\usepackage{amssymb}\usepackage{mathrsfs}\usepackage{tikz-cd}\usepackage{tikz}\begin{document}
\begin{displaymath}
.\begin{tikzcd} & A \arrow[rd, "\alpha"] & \\Q \arrow[ru, "f"] \arrow[rd, "g"'] &   & C \\ & B \arrow[ru, "\beta"'] &  \end{tikzcd}\end{displaymath}
\end{document}
Due to external code I am using, I have to use imagemagick's convert function to turn this into a .png, and I can supply any arguments I wish. However, no matter what combinations flags I try, the images invariably have their lower half removed. Here is
an example of that happening: http://web.stanford.edu/~ksb/content/X1.3.9.html

Does anyone have suggestions for what could be responsible for this behavior?

Mac OS Mojave
ImageMagick 7.0.8-42 Q16 x86_64 2019-04-28
ghostscript version 9.26

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lower half of tikzcd images truncated by convert

Post by fmw42 » 2019-06-12T08:21:34-07:00

Post one of your PS files so we can test. Also GS 9.26 has been know to be buggy as is 9.27. Try downgrading to 9.23 - 9.25

ksb
Posts: 3
Joined: 2019-06-12T00:52:42-07:00
Authentication code: 1152

Re: Lower half of tikzcd images truncated by convert

Post by ksb » 2019-06-12T10:44:00-07:00

Unfortunately brew does not seem to have older versions of ghostscript available. Here is a link to the .ps file content https://pastebin.com/tPn57Z5m. Thanks!

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lower half of tikzcd images truncated by convert

Post by fmw42 » 2019-06-12T11:29:34-07:00

As best as I can tell, it is not ImageMagick truncating it. Your PS file has a ps:HiResBoundingBox: 178x90+245+603 that limits what is used and tells IM what to convert. I see the same result using Mac Preview and Photoshop.

ksb
Posts: 3
Joined: 2019-06-12T00:52:42-07:00
Authentication code: 1152

Re: Lower half of tikzcd images truncated by convert

Post by ksb » 2019-06-12T13:57:32-07:00

Thanks, you're right that the bounding box was responsible! (I'll try to figure out why dvips -E gives incorrect bounds)

Post Reply