I've written a non linear transform and am able to transform figures drawn in TiKZ correctly (transformed the rectangle on the left to the arc on the right) but doing the same on \includegraphics doesn't work. How can I apply the same transformation on it ? Here's the code I have for transformation
%!tikz editor 1.0
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
\usepgfmodule{nonlineartransformations}
\usepgfmodule[nonlineartransformations]
\usepackage{mathtools}
\makeatletter
\newcommand*{\length}{50}%
\newcommand*{\width}{20}%
\newcommand*{\PI}{3.14}%
\newcommand*{\Rad}{30}%
\newcommand*{\rad}{27.5}%
\newcommand*{\slant}{20}%
\pgfmathsetmacro{\alpha}{(2*\PI*(\Rad-\rad))/\slant}%
\pgfmathsetmacro{\tconst}{(\rad*\slant)/(\Rad-\rad)}%
\tikzset{declare function={zeta(\x,\y) = \tconst + ((\x*\slant)/\length);}}
\tikzset{declare function={theta(\x,\y)=(\alpha*\y)/\width;}}
\tikzset{declare function={shi(\x)=\x+60;}}
\def\polartransformation
{
\pgfmathsetmacro{\costheta}{cos(deg(theta(\pgf@x,\pgf@y)))}
\pgfmathsetmacro{\sintheta}{sin(deg(theta(\pgf@x,\pgf@y)))}
\pgfmathsetmacro{\resz}{zeta(\pgf@x,\pgf@y)}
\pgfmathsetmacro{\xcoord}{\resz*\costheta}
\pgfmathsetmacro{\ycoord}{\resz*\sintheta}
\setlength{\pgf@x}{\xcoord pt}
\setlength{\pgf@y}{\ycoord pt}
}
\makeatother
%!tikz preamble end
\begin{document}
%!tikz source begin
\begin{tikzpicture}
\draw [black, left color=white, right color=gray ] (100pt,20pt) rectangle (150pt,0pt);
{
\pgftransformnonlinear{\polartransformation}
\pgfsettransformnonlinearflatness{0.2pt}
\draw [black, left color=white, right color=gray ] (0pt,20pt) rectangle (50pt,0pt);
}
\end{tikzpicture}
%!tikz source end
\end{document}

