externalfigure and width/height scaling
Hello, I am new to ConTeXt, so please be patient with my newbie questions. Looking at the \externalfigure capabilities, I haven't found any option allowing to scale only one dimension (or scale both dimensions in an anamorphous way). Am I right, and if so what is the best method to perform this? I thought about using the \getfiguredimensions macro to get the natural dimensions, and then use something like width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the externalfigure interface does not allow this directly (something like wscale and hscale options). Regards, BG
nico wrote:
Hello,
I am new to ConTeXt, so please be patient with my newbie questions. Looking at the \externalfigure capabilities, I haven't found any option allowing to scale only one dimension (or scale both dimensions in an anamorphous way).
Am I right, and if so what is the best method to perform this?
I thought about using the \getfiguredimensions macro to get the natural dimensions, and then use something like width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the externalfigure interface does not allow this directly (something like wscale and hscale options).
there is indeed no xscale and yscale (although \scale[sx=1.5,sy=2,3]{...} is available) % put this in cont-new.tex \unprotect \let\@@efxscale\empty \let\@@efyscale\empty \def\setnaturalfiguresize {\doifsomething\@@efwidth {\global\figwid\@@efwidth}% \doifsomething\@@efheight {\global\fighei\@@efheight}% \doifsomething\@@efscale {\figxsca\@@efscale \figysca\@@efscale}% \doifsomething\@@efxscale {\figxsca\@@efxscale}% \doifsomething\@@efyscale {\figxsca\@@efyscale}} \def\setscalefiguresize {\doifsomething{\@@efscale\@@efxscale\@@efxscale} {\doapplyfigurescale\figwid\@@epw\figxsca\@@efxscale \doapplyfigurescale\fighei\@@eph\figysca\@@efyscale \global\figwid\zeropoint \global\fighei\zeropoint \doifelsenothing\@@efmaxwidth {\doifsomething\@@efmaxheight {\ifdim\@@eph>\@@efmaxheight \global\fighei\@@efmaxheight \fi}} {\ifdim\@@epw>\@@efmaxwidth \global\figwid\@@efmaxwidth \fi}}} \def\doapplyfigurescale#1#2#3#4% {\ifcase0#4\relax % @@ef.scale kan empty zijn \ifcase0\@@efscale\relax % @@efscale kan empty zijn #3=\plusthousand \else #3=\@@efscale \fi \else #3=#4% \fi \relax % important ! \global#1\ifnum#3=\plusthousand#2\else\dimexpr#3\dimexpr#2/\plusthousand\relax\relax\fi \relax} \def\setdimensionfiguresize {\ifdim\figwid>\zeropoint\relax \ifdim\fighei>\zeropoint\relax \dosetdimensionfiguresize {\docalculatefigurescale\fighei\@@eph\figysca \docalculatefigurescale\figwid\@@epw\figxsca}% {\docalculatefigurescale\fighei\@@eph\figysca \docalculatefigurescale\figwid\@@epw\figxsca}% {\docalculatefigurescale\fighei\@@eph\figysca \docalculatefigurescale\figwid\@@epw\figxsca}% \else \dosetdimensionfiguresize {\docalculatefigurescales\figwid\@@epw\fighei\@@eph}% {\docalculatefigurescales\figwid\@@epw\fighei\@@eph}% {\docalculatefigurescales\figwid\@@epw\fighei\@@eph}% \fi \else \ifdim\fighei>\zeropoint\relax \dosetdimensionfiguresize {\docalculatefigurescales\fighei\@@eph\figwid\@@epw}% {\docalculatefigurescales\fighei\@@eph\figwid\@@epw}% {\docalculatefigurescales\fighei\@@eph\figwid\@@epw}% \else \dosetdimensionfiguresize {\doapplyfigurescale\figwid\@@epw\figxsca\@@efxscale \doapplyfigurescale\fighei\@@eph\figysca\@@efyscale}% {\docalculatefigurescales\figwid\@@epw\fighei\@@eph}% {\docalculatefigurescales\fighei\@@eph\figwid\@@epw}% \fi \fi} \protect % end of patch \starttext \externalfigure[cow][scale=1000] \externalfigure[cow][scale=200] \externalfigure[cow][yscale=200] \externalfigure[cow][xscale=800,yscale=200] \stoptext
On Sun, 12 Mar 2006 20:02:44 +0100, Hans Hagen
nico wrote:
Looking at the \externalfigure capabilities, I haven't found any option allowing to scale only one dimension (or scale both dimensions in an anamorphous way).
Am I right, and if so what is the best method to perform this?
I thought about using the \getfiguredimensions macro to get the natural dimensions, and then use something like width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the externalfigure interface does not allow this directly (something like wscale and hscale options).
there is indeed no xscale and yscale (although \scale[sx=1.5,sy=2,3]{...} is available)
% put this in cont-new.tex
Thanks very much for your quick patch, it works as expected. Do you plan to include it in a next release? Regards, BG
nico wrote:
On Sun, 12 Mar 2006 20:02:44 +0100, Hans Hagen
wrote: nico wrote:
Looking at the \externalfigure capabilities, I haven't found any option allowing to scale only one dimension (or scale both dimensions in an anamorphous way).
Am I right, and if so what is the best method to perform this?
I thought about using the \getfiguredimensions macro to get the natural dimensions, and then use something like width=0.2\imgwidth,height=0.8\imgheight, but it is a pity that the externalfigure interface does not allow this directly (something like wscale and hscale options).
there is indeed no xscale and yscale (although \scale[sx=1.5,sy=2,3]{...} is available)
% put this in cont-new.tex
Thanks very much for your quick patch, it works as expected. Do you plan to include it in a next release?
yes Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
nico