HarisIqbal88 / PlotNeuralNet

Latex code for making neural networks diagrams
MIT License
21.54k stars 2.83k forks source link

How to generate PNG images? #138

Open kobeis007 opened 1 year ago

kobeis007 commented 1 year ago

How to generate PNG images?

turing0 commented 1 year ago

I want to know too

GuoDapeng commented 3 months ago

我刚刚接触这个有趣的工具,生成 PNG 图片需要在生成 PDF 文件之后,将 PDF 转换成 PNG。下面是在 macOS 上面的办法。

安装 ImageMagick 工具包

brew install imagemagick

修改 tikzmake.sh 脚本

#!/bin/bash

python $1.py 
pdflatex $1.tex

rm *.aux *.log *.vscodeLog
rm *.tex

convert -density 300 $1.pdf $1.png
rm *.pdf

if [[ "$OSTYPE" == "darwin"* ]]; then
    open $1.png
else
    xdg-open $1.png
fi

完成。

解释:

convert -density 300 $1.pdf $1.png

这是将 PDF 转换成 PNG 的命令。-density 300 这个选项,将获得一个解析度更好的 PNG 图片。