答案1
我认为最好的方法是使用tikz
剪切路径将其剪切到那里。为此,您需要先将图像保存到保存框中,以便知道尺寸。然后,您首先将边界框限制为原始图像大小并添加剪切路径。
要使用圆弧进行剪辑,请使用以下代码:
\documentclass{article}
\usepackage{tikz}
\newsavebox\mysavebox
\begin{document}
\begin{tikzpicture}
\savebox\mysavebox{\includegraphics[width=.9\textwidth]{example-image-1x1}}
\path [use as bounding box] rectangle (\wd\mysavebox, \ht\mysavebox);
\path [draw,clip] (0, 0) arc [start angle=180, end angle=90, radius=\wd\mysavebox] -- (\wd\mysavebox, 0) -- cycle;
\node [anchor=south west, inner sep=0pt, outer sep=0pt] at (0,0) {\usebox\mysavebox};
\end{tikzpicture}
\end{document}
要使用圆圈剪辑图像,请使用以下代码:
\documentclass{article}
\usepackage{tikz}
\newsavebox\mysavebox
\begin{document}
\begin{tikzpicture}
\savebox\mysavebox{\includegraphics[width=.9\textwidth]{example-image-1x1}}
\path [use as bounding box] rectangle (\wd\mysavebox, \ht\mysavebox);
\path [clip] (.5\wd\mysavebox, .5\ht\mysavebox) circle (.5\wd\mysavebox);
\node [anchor=south west, inner sep=0pt, outer sep=0pt] at (0,0) {\usebox\mysavebox};
\end{tikzpicture}
\end{document}
您还可以使用极坐标获得有角度的剪切路径。我(45:100)
在这里使用的是 45 度。半径为 100 厘米,因此它比图像大,这是因为我们事先固定了边界框,所以这不会增加生成的图片大小。
由于剪切路径可以任意,因此您拥有很大的自由。
\documentclass{article}
\usepackage{tikz}
\newsavebox\mysavebox
\begin{document}
\begin{tikzpicture}
\savebox\mysavebox{\includegraphics[width=.9\textwidth]{example-image}}
\path [use as bounding box] rectangle (\wd\mysavebox, \ht\mysavebox);
\path [clip] (0,0) -- (45:100) -- (0:100) -- cycle;
\node [anchor=south west, inner sep=0pt, outer sep=0pt] at (0,0) {\usebox\mysavebox};
\end{tikzpicture}
\end{document}