Hi Hans, Could you please add these 2 patches (or something similar), because the grph-downsample module¹ would work much better then: 1.) To get the width and the height into the name of the file, because when the figure dimensions change, there must be a new conversion: --8<---------------cut here---------------start------------->8--- --- grph-inc.lua~ 2012-06-05 10:37:01.000000000 +0200 +++ grph-inc.lua 2012-07-31 22:40:39.214426838 +0200 @@ -528,6 +528,9 @@ if resolution and resolution ~= "" then -- the order might change newbase = newbase .. "_" .. resolution end + local width = figures.current().request.width + local height = figures.current().request.height + newbase = newbase .. "_" .. width .. "_" .. height -- -- see *, we had: -- --8<---------------cut here---------------end--------------->8--- 2.) To avoid crap in the width and height options: --8<---------------cut here---------------start------------->8--- --- grph-inc.mkiv~ 2012-07-20 23:26:52.000000000 +0200 +++ grph-inc.mkiv 2012-08-01 00:02:23.851094854 +0200 @@ -293,6 +293,10 @@ % \the\t_grph_include_local_settings \dostarttagged\t!image\empty + \edef\current_width{\externalfigureparameter\c!width}% + \edef\current_height{\externalfigureparameter\c!height}% + \def\nocrap##1{\doifnotemptyvalue{##1}{% + \the\dimexpr\csname##1\endcsname\relax}}% \ctxlua{figures.push { name = "\p_grph_include_name", label = "\p_grph_include_label", @@ -312,8 +316,8 @@ resolution = "\externalfigureparameter\c!resolution", color = "\internalspotcolorparent{\externalfigureparameter\c!color}", % hack is needed ["repeat"] = "\externalfigureparameter\c!repeat", - width = "\externalfigureparameter\c!width", % can be crap - height = "\externalfigureparameter\c!height", % can be crap + width = "\nocrap{current_width}", % no more crap + height = "\nocrap{current_height}", % no more crap } }% \ctxlua{figures.identify()}% % also mode: checkpresense only --8<---------------cut here---------------end--------------->8--- ¹ http://modules.contextgarden.net/grph-downsample TIA, -- Peter
On Fri, 7 Sep 2012, Peter Münster wrote:
2.) To avoid crap in the width and height options:
--8<---------------cut here---------------start------------->8--- --- grph-inc.mkiv~ 2012-07-20 23:26:52.000000000 +0200 +++ grph-inc.mkiv 2012-08-01 00:02:23.851094854 +0200 @@ -293,6 +293,10 @@ % \the\t_grph_include_local_settings \dostarttagged\t!image\empty + \edef\current_width{\externalfigureparameter\c!width}% + \edef\current_height{\externalfigureparameter\c!height}% + \def\nocrap##1{\doifnotemptyvalue{##1}{% + \the\dimexpr\csname##1\endcsname\relax}}%
It is better to use a more meaningful name. This can be a general macro that will be useful outside of the figure inclusion code as well.
\ctxlua{figures.push { name = "\p_grph_include_name", label = "\p_grph_include_label", @@ -312,8 +316,8 @@ resolution = "\externalfigureparameter\c!resolution", color = "\internalspotcolorparent{\externalfigureparameter\c!color}", % hack is needed ["repeat"] = "\externalfigureparameter\c!repeat", - width = "\externalfigureparameter\c!width", % can be crap - height = "\externalfigureparameter\c!height", % can be crap + width = "\nocrap{current_width}", % no more crap + height = "\nocrap{current_height}", % no more crap } }%
Aditya
On Fri, Sep 07 2012, Aditya Mahajan wrote:
+ \edef\current_width{\externalfigureparameter\c!width}% + \edef\current_height{\externalfigureparameter\c!height}% + \def\nocrap##1{\doifnotemptyvalue{##1}{% + \the\dimexpr\csname##1\endcsname\relax}}%
It is better to use a more meaningful name. This can be a general macro that will be useful outside of the figure inclusion code as well.
Ok. What about \scratch_current_width, \scratch_current_height, \scratch_nocrap ? Or something similar... -- Peter
On Thu, 13 Sep 2012, Peter Münster wrote:
On Fri, Sep 07 2012, Aditya Mahajan wrote:
+ \edef\current_width{\externalfigureparameter\c!width}% + \edef\current_height{\externalfigureparameter\c!height}% + \def\nocrap##1{\doifnotemptyvalue{##1}{% + \the\dimexpr\csname##1\endcsname\relax}}%
It is better to use a more meaningful name. This can be a general macro that will be useful outside of the figure inclusion code as well.
Ok. What about \scratch_current_width, \scratch_current_height, \scratch_nocrap ? Or something similar...
Hans already added a generic function \setemeasure to syst-aux, that can be used here. Note that a simple \doifnotemptyvalue is not enough. I can pass values like 'fit', 'max', etc to height and width keys, so you must check if what is being passed is a dimension before calling \dimexpr. Aditya
On Fri, Sep 14 2012, Aditya Mahajan wrote:
Hans already added a generic function \setemeasure to syst-aux, that can be used here.
Thanks, I'll take a look.
Note that a simple \doifnotemptyvalue is not enough. I can pass values like 'fit', 'max', etc to height and width keys, so you must check if what is being passed is a dimension before calling \dimexpr.
Are you sure? According to http://wiki.contextgarden.net/Command/useexternalfigure you have to pass `fit' and `max' to `factor='. -- Peter
participants (2)
-
Aditya Mahajan
-
Peter Münster