http://zorba.io/modules/image/basic

View as XML or JSON.

This module provides function to do the following basic image operations:

  • create empty images
  • compare images
  • compress image
  • convert an image one format to another
  • retrieve with, height, format, and exif information from an image

The following image formats are supported:

  • GIF
  • JPEG
  • PNG
  • TIFF
  • BMP

The errors raised by functions of this module have the namespace http://zorba.io/modules/image/error (associated with prefix ierr).

Function Summary

compress ($image as xs:base64Binary, $quality as xs:unsignedInt) as xs:base64Binary external

Compresses the passed image.

convert-svg-string ($svg as xs:string, $format as xs:string) as xs:base64Binary

Converts an SVG image to a supported image format.

convert-svg ($svg as element(svg:svg), $format as xs:string) as xs:base64Binary

Converts an SVG image to a supported image format.

convert ($image as xs:base64Binary, $format as xs:string) as xs:base64Binary

Converts an image to another format.

create ($width as xs:unsignedInt, $height as xs:unsignedInt, $format as xs:string) as xs:base64Binary

Creates an empty image with background color white.

equals ($image1 as xs:base64Binary, $image2 as xs:base64Binary) as xs:boolean external

Compares two images.

exif ($image as xs:base64Binary, $tag as xs:string) as xs:string? external

Reads exif information from an image.

format ($image as xs:base64Binary) as xs:string external

Returns the format of the passed image.

height ($image as xs:base64Binary) as xs:unsignedInt external

Returns the height of the passed image.

width ($image as xs:base64Binary) as xs:unsignedInt external

Returns the width of the passed image.

Functions

compress#2

declare  function basic:compress($image as xs:base64Binary, $quality as xs:unsignedInt) as xs:base64Binary external

Compresses the passed image.

Compressing means lowering the quality and reducing the size.

Parameters

image as xs:base64Binary
the image
quality as xs:unsignedInt
compression level, 0 to 100

Returns

xs:base64Binary
the compressed image

convert-svg-string#2

declare  function basic:convert-svg-string($svg as xs:string, $format as xs:string) as xs:base64Binary

Converts an SVG image to a supported image format.

Parameters

svg as xs:string
the image to convert as string
format as xs:string
target format

Returns

xs:base64Binary
the resulting image

convert-svg#2

declare  function basic:convert-svg($svg as element(svg:svg), $format as xs:string) as xs:base64Binary

Converts an SVG image to a supported image format.

Parameters

svg as element(svg:svg)
the image to convert
format as xs:string
target format

Returns

xs:base64Binary
the resulting image

convert#2

declare  function basic:convert($image as xs:base64Binary, $format as xs:string) as xs:base64Binary

Converts an image to another format.

Parameters

image as xs:base64Binary
the source image
format as xs:string
the format (see supported formats above) of the resulting image.

Returns

xs:base64Binary
A new image with the same content as the passed image but with the specified file format.

create#3

declare  function basic:create($width as xs:unsignedInt, $height as xs:unsignedInt, $format as xs:string) as xs:base64Binary

Creates an empty image with background color white.

Parameters

width as xs:unsignedInt
the width of the new image
height as xs:unsignedInt
the height of the new image
format as xs:string
the format of the new image

Returns

xs:base64Binary
newly created image

equals#2

declare  function basic:equals($image1 as xs:base64Binary, $image2 as xs:base64Binary) as xs:boolean external

Compares two images.

Parameters

image1 as xs:base64Binary
first image
image2 as xs:base64Binary
second image

Returns

xs:boolean
True if the images are equal.

exif#2

declare  function basic:exif($image as xs:base64Binary, $tag as xs:string) as xs:string? external

Reads exif information from an image.

This function works for JPEG and TIFF images only.

It returns empty sequence if no exif information matching the passed tag is found.

Parameters

image as xs:base64Binary
the image
tag as xs:string
the field name we want read (e.g. DateTime).

Returns

xs:string?
exif field content

format#1

declare  function basic:format($image as xs:base64Binary) as xs:string external

Returns the format of the passed image.

Parameters

image as xs:base64Binary
the image

Returns

xs:string
the format

height#1

declare  function basic:height($image as xs:base64Binary) as xs:unsignedInt external

Returns the height of the passed image.

Parameters

image as xs:base64Binary
the image

Returns

xs:unsignedInt
the height in pixels

width#1

declare  function basic:width($image as xs:base64Binary) as xs:unsignedInt external

Returns the width of the passed image.

Parameters

image as xs:base64Binary
the image

Returns

xs:unsignedInt
the width in pixels