Pinch effect in ImageMagick

September 5, 2008

Here’s another ImageMagick hack inspired by PhotoBooth on my Mac. Create a file named “pinch.fx” with the following content, without line numbers:
kk=w*0.5;
ll=h*0.5;
dx=(i-kk);
dy=(j-ll);
aa=atan2(dy,dx);
rr=hypot(dy,dx);
rs=sqrt(rr*200);
px=kk+rs*cos(aa);
py=ll+rs*sin(aa);
p{px,py}
As with the fisheye effect, we first compute the polar coordinates of the current pixel in lines 1-7. Next, I compute a scaled radius as the square root of the current radius. [...]

0