General ⇒ Shaping an Image
Shaping an Image
I new to Latex and I want to know if there is a way to cropping pictures into non-rectangular shapes in Latex
Tks...
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Shaping an Image
Best regards an welcome on Board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Shaping an Image
Code: Select all
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\includegraphics{ctanlion.jpg}
\caption{The whole \TeX\ lion.}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}
\clip (0,0) circle (4cm);
\pgftext{\includegraphics{ctanlion.jpg}};
\end{tikzpicture}
\caption{The \TeX\ lion cropped by a circle.}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}
\clip (0,4) ..controls +(120:2cm)
and +(90:2cm) .. (-4,3) .. controls +(-90:2cm) and +(90:3cm) ..
(0,-5) .. controls +(90:3cm) and +(-90:2cm) ..(4,3) .. controls
+(90:2cm) and +(60:2cm) .. (0,4);
\pgftext{\includegraphics{ctanlion.jpg}};
\end{tikzpicture}
\caption{The \TeX\ lion cropped by a heart.}
\end{figure}
\end{document}
Edited: The lion's image can be obtained at different formats and resolutions from http://www.ctan.org/lion.html
The path for the cropping heart has been borrowed (and slightly modified) from http://www.fauskes.net/pgftikzexamples/valentine-heart/
- Attachments
-
- ctanlion.jpg (37.3 KiB) Viewed 4780 times