23

I am trying to create a fancy image by clipping an external image by an ellipse- the area inside the ellipse will be shown only. I have seen this, but I still need help. Can anybody help?

Here's an instance of what I am saying:

img

2

2 Answers 2

16

With PSTricks just for fun.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=1]{example-grid-100x100pt}}
\psset
{
    xunit=.1\wd\IBox,
    yunit=.1\ht\IBox,
}
\begin{document}
\begin{pspicture}(10,10)
    \psclip{\psellipse(5,5)(5,4)}
    \rput(5,5){\usebox\IBox}
    \endpsclip
\end{pspicture}
\end{document}

enter image description here

Bonus

An elliptical batman clipping path.

\documentclass[pstricks,border=0pt]{standalone}
\SpecialCoor
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=1]{example-grid-100x100pt}}
\psset
{
    xunit=\dimexpr\wd\IBox/14,
    yunit=\dimexpr\ht\IBox/14,
}

% b a t p2c ---> x y
% where b (semi-minor), a (semi-major), t (theta)
\pstVerb{/p2c {dup 3 1 roll cos mul 3 1 roll sin mul} bind def}


\def\RightPart
{
    \psline(0.5,2.7)(1,3.25)
    \psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
    \psbezier(3.0,1.0)(3.0,2.2)(!3.3 6.0 72 p2c)
    \psellipticarcn(6.0,3.3){(!3.3 6.0 72 p2c)}{(!3.3 6.0 72 neg p2c)}
    \psbezier(4,-2)(4,0)(2.2,-1.8)
    \psbezier(1.5,-1)(1,-1)(0,-3.2)
}


\begin{document}

\begin{pspicture}(-7,-4)(7,4)
\psclip{
    \pscustom[dimen=monkey]
    {
    \RightPart
    \reversepath
    \scale{-1 1}
    \RightPart
    \closepath
    }}
    \rput(0,0){\usebox\IBox}
\endpsclip
\end{pspicture}
\end{document}

enter image description here

2
  • 6
    How did you manage with the Batman logo thingy? Looks amazing...
    – azetina
    Jan 19, 2014 at 18:11
  • 1
    @azetina: By trial and error approach to find the best coordinates. Jan 19, 2014 at 18:12
27

With TikZ

Code

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usepackage{mwe} % provides example-image-a
\begin{document}
\begin{tikzpicture}
    \clip(0,0)circle[x radius=4cm, y radius=2cm];
    \node{\includegraphics{example-image-a}};   
\end{tikzpicture}
\end{document}

Output

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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