Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
3  
Section 15.5 of the pgfmanual is about this topic and gives an explicit example on how to do that. Does this help? –  Bordaigorl Jan 19 at 16:34
3  

2 Answers 2

up vote 15 down vote accepted

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

share|improve this answer
6  
How did you manage with the Batman logo thingy? Looks amazing... –  azetina Jan 19 at 18:11
1  
@azetina: By trial and error approach to find the best coordinates. –  stalking is prohibited Jan 19 at 18:12
1  
@Pleasedon'ttouch Your user profile looks nice! :D –  pushpen.paul Jul 19 at 15:18
    
@pushpen.paul: Thanks for liking it. :-) –  stalking is prohibited Jul 19 at 15:29

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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