Convert

Syntax

convert <quoted-from-media-type : string> <quoted-to-media-type : string> <transcoding-params : string-list> ;

Description

The "convert" action specifies that all body parts with a media type [RFC2046] (sometimes called "MIME type") equal to <quoted-from-media-type> be converted to the media type in <quoted-to-media-type> using conversion parameters specified in <transcoding-params>. Each conversion parameter value has the following syntax: "<transcoding-param-name>=<transcoding-param-value>", where <transcoding-param-name> and <transcoding-param-value> are defined in CONVERT [RFC5259]. Messages that don't have any body parts with the <quoted-from-media-type> media type are not affected by the conversion.

The "convert" action can be used with Sieve MIME Part Tests [RFC5703], in the case that some, but not all of the body parts need to be converted, or where different body parts might require different conversions. When the "convert" action appears in a "foreverypart" loop, it applies only to the body part being processed, and not to any other body parts.

When the "convert" action appears outside a "foreverypart" loop, the conversion applies equally to all body parts -- that is, all body parts that have the "quoted-from-media-type" are converted, using the same transcoding parameters.

A single "convert" action will only apply once to any body part. If, for example, convert "image/jpeg" "image/jpeg" ["pix-x=100","pix-y=120"] converts a larger JPEG image to the smaller 100 x 120 size, that will be the end of that "convert" action on that body part. The action will not see a "new" JPEG body part to process, resulting from the conversion.

If a "convert" action cannot be completed -- perhaps because the conversion failed, or because the requested conversion is not available -- that "convert" action MUST terminate and leave the message unchanged, rolling back any other conversions done by that action. The script processing continues, and prior or subsequent "convert" actions are not affected. No error condition is raised, and no partial conversions from a single "convert" action are allowed.

Example

In the following example, all "image/tiff" body parts of the message are converted to "image/jpeg" with image resolution of 320x240 pixels. The converted message is then subject to the implicit keep.

require ["convert"]; convert "image/tiff" "image/jpeg" ["pix-x=320","pix-y=240"];

Module

Convert : Requires import of the "convert" capability

Resources

RFC6558
RFC5259