mt-transform-image(Base64Image as Base64BinaryString, Size as item()+, Rotation as xs:integer, Quality as xs:integer) as Base64BinaryStringXP3.1XQ3.1
Takes a Base64-encoded image as its first argument and returns a transformed Base64-encoded image. The second, third, and fourth arguments are the image parameters that are transformed: size, rotation, and quality.
•The Size argument provides three resizing options.
(X,Y)
Absolute pixel values. The aspect ratio is not maintained. The order of height and width does not matter since height and width are automatically selected according to the long and short sides of the image. The value is entered as a sequence of two integer items; the parentheses are required.
X
Proportionally resizes the image with X as the new longer side in pixels; aspect ratio is maintained. The value is an integer, and is entered without quotes.
'X%'
Resizes the image to the given percentage of the original dimensions. The value must be entered as a string, in quotes.
•Rotation can be one of the following values: 90, 180, 270, -90, -180, -270. These are rotation values in degrees of a circle. Positive values rotate the image clockwise; negative values rotate the image counter-clockwise. Note that you can use the Altova Exif attribute OrientationDegree to obtain the current rotation of the image in degrees (0, 90, 180, 270) from the Exif Orientation tag of the image. However, since the OrientationDegree attribute is obtained from the Orientation tag of the Exif data, it will be available only if the Orientation tag is present in the Exif data (see the description of OrientationDegree below).
•Quality can be any value between 0 and 100 and refers to values on the IJG quality scale for JPEG compression; it is not a percentage indicator of quality. The tradeoff is between file size and quality. For a full-color source image, 75 is generally considered an optimal value. If 75 produces unsatisfactory results, increase the value.
Note: If Exif data is present in the original image, it will be removed during the transformation, and the transformed image will not contain Exif data.
•mt-transform-image(Images/Image[@id='43'], '50%', 90, 75) The function takes as its input an image that is stored as a Base64-encoded string in the descendant Images/Image node that has an @id value of 43. The function returns a transformed image. The transformed image is resized to 50%, rotated 90 degrees clockwise, and given a quality level of 75.
•mt-transform-image(Images/Image[@id='43'], 400, 90, 75) The function produces the same result as the previous example, except that the long side is set to a specific value of 400 pixels; the aspect ratio of the original image is maintained.
•mt-transform-image(Images/Image[@id='43'], (400, 280), image-exif-data($XML1/$XML1/Images/ReferenceImage)/@OrientationDegree, 75) This example selects the same image as in the previous examples, and sets the same quality value (75). The image size is set at 400x280 pixels, and the Rotation value is obtained from the @OrientationDegree attribute of a Base64-encoded image in the ReferenceImage node.
La machine Altova XPath/XQuery génère l'attribut personnalisé OrientationDegree à partir de l'onglet de métadonnées Exif Orientation.
OrientationDegree traduit l'onglet standard Exif Orientation à partir d'une valeur d'entier (1, 8, 3, ou 6) aux valeurs de degrés respectives de chacun (0, 90, 180, 270), tel que montré dans la figure ci-dessous. Veuillez noter qu'il n'y a pas de traductions de la valeur Orientation de 2, 4, 5, 7. (Ces orientations sont obtenus en basculant l'image 1 à travers son centre axial vertical pour obtenir l'image avec une valeur de 2, puis en pivotant cette image par sauts de 90° dans le sens des aiguilles d'une montre pour obtenir les valeurs de 7, 4, et 5, respectivement).