Command macros command-macros

Command macros provide named shortcuts for sets of commands.

Macros are defined in separate macro definition files, which can be attached to image catalogs or the default catalog.

Macros may be invoked anywhere in a request after the ‘?’, and anywhere within a catalog::Modifier field. Macros can only represent one or more full Image Serving commands, therefore it must be enclosed by ‘&’ separators (except when at the beginning or end of the modifier string).

Macro invocations are replaced by their substitution strings early during parsing. Commands within macros override the same commands in the request if they occur before the macro invocation in the request. This flow is different from catalog::Modifier, where commands in the request string always override commands in the catalog::Modifier string, regardless of the position in the request.

Macros can be nested. However, a macro can only be invoked if it is already defined at the time the macro definition is parsed. This flow is accomplished either by appearing earlier in the same macro definition file, or by placing the definition for such an embedded macro in the default macro definition file.

Macros can be useful if the same attributes are to be applied to different images.




You can define a macro for the common attributes:

view wid=240&fmt=pdf&imageRes=300

The macro would be used as follows:




Because wid= is different for the third request, you simply override the value after the macro is invoked (specifying wid= before $view$ has no effect).