http://www.zorba-xquery.com/modules/image/basic ZC

Module Description
Before using any of the functions below please remember to import the module namespace:
import module namespace basic = "http://www.zorba-xquery.com/modules/image/basic";

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://www.zorba-xquery.com/modules/image/error (associated with prefix ierr).

Author:

Daniel Thomas

XQuery version and encoding for this module:

xquery version "3.0" encoding "utf-8";

Module Resources
  • the XQuery module can be found here.
Module Dependencies

Imported schemas:

External C++ library dependencies:

Namespaces
basic http://www.zorba-xquery.com/modules/image/basic
err http://www.w3.org/2005/xqt-errors
ierr http://www.zorba-xquery.com/modules/image/error
image http://www.zorba-xquery.com/modules/image/image
ver http://www.zorba-xquery.com/options/versioning
Function Summary
compress ( $image as xs:base64Binary, $quality as xs:unsignedInt ) as xs:base64Binary external
Compresses the passed image.
convert ( $image as xs:base64Binary, $format as xs:string ) as xs:base64Binary
Converts an image to another format.
convert-svg ( $svg as xs:base64Binary, $format as xs:string ) as xs:base64Binary
Converts an SVG image to a supported image 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 back to 'Function Summary'
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 the image
  • $quality compression level, 0 to 100
Returns:
  • the compressed image
Errors:
  • ierr:IM001 the passed image is invalid.
Examples:

convert back to 'Function Summary'
declare function basic:convert (
            $image as xs:base64Binary, 
            $format as xs:string 
 ) as xs:base64Binary

Converts an image to another format.

Parameters:
  • $image the source image
  • $format the format (see supported formats above) of the resulting image.
Returns:
  • A new image with the same content as the passed image but with the specified file format.
Errors:
  • ierr:IM001 the passed image is invalid.
  • err:FORG0001 unsupported image format
Examples:

convert-svg back to 'Function Summary'
declare function basic:convert-svg (
            $svg as xs:base64Binary, 
            $format as xs:string 
 ) as xs:base64Binary

Converts an SVG image to a supported image format.

Parameters:
  • $svg the image to convert
  • $format target format
Returns:
  • the resulting image
Errors:
  • ierr:IM001 the passed SVG is invalid.
Examples:

create back to 'Function Summary'
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 the width of the new image
  • $height the height of the new image
  • $format the format of the new image
Returns:
  • newly created image
Errors:
  • err:FORG0001 unsupported image format
Examples:

equals back to 'Function Summary'
declare function basic:equals (
            $image1 as xs:base64Binary, 
            $image2 as xs:base64Binary 
 ) as xs:boolean external

Compares two images.

Parameters:
  • $image1 first image
  • $image2 second image
Returns:
  • True if the images are equal.
Errors:
  • ierr:IM001 one of the passed images is invalid.
Examples:

exif back to 'Function Summary'
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 the image
  • $tag the field name we want read (e.g. DateTime).
Returns:
  • exif field content
Errors:
  • ierr:IM001 the passed image is invalid.
Examples:

format back to 'Function Summary'
declare function basic:format (
            $image as xs:base64Binary 
 ) as xs:string external

Returns the format of the passed image.

Parameters:
  • $image the image
Returns:
  • the format
Errors:
  • ierr:IM001 the passed image is invalid.
Examples:

height back to 'Function Summary'
declare function basic:height (
            $image as xs:base64Binary 
 ) as xs:unsignedInt external

Returns the height of the passed image.

Parameters:
  • $image the image
Returns:
  • the height in pixels
Errors:
  • ierr:IM001 the passed image is invalid.
Examples:

width back to 'Function Summary'
declare function basic:width (
            $image as xs:base64Binary 
 ) as xs:unsignedInt external

Returns the width of the passed image.

Parameters:
  • $image the image
Returns:
  • the width in pixels
Errors:
  • ierr:IM001 the passed image is invalid.
Examples:

blog comments powered by Disqus