http://www.zorba-xquery.com/modules/image/basic
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
- 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).
Daniel Thomas
xquery version "3.0" encoding "utf-8";
- the XQuery module can be found here.
Imported schemas:
External C++ library dependencies:
| 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 |
|
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. |
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.
- $image the image
- $quality compression level, 0 to 100
- the compressed image
- ierr:IM001 the passed image is invalid.
declare function basic:convert ( $image as xs:base64Binary, $format as xs:string ) as xs:base64Binary
Converts an image to another format.
- $image the source image
- $format the format (see supported formats above) of the resulting image.
- A new image with the same content as the passed image but with the specified file format.
- ierr:IM001 the passed image is invalid.
- err:FORG0001 unsupported image format
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.
- $svg the image to convert
- $format target format
- the resulting image
- ierr:IM001 the passed SVG is invalid.
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.
- $width the width of the new image
- $height the height of the new image
- $format the format of the new image
- newly created image
- err:FORG0001 unsupported image format
declare function basic:equals ( $image1 as xs:base64Binary, $image2 as xs:base64Binary ) as xs:boolean external
Compares two images.
- $image1 first image
- $image2 second image
- True if the images are equal.
- ierr:IM001 one of the passed images is invalid.
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.
- $image the image
- $tag the field name we want read (e.g. DateTime).
- exif field content
- ierr:IM001 the passed image is invalid.
declare function basic:format (
$image as xs:base64Binary
) as xs:string external
Returns the format of the passed image.
- $image the image
- the format
- ierr:IM001 the passed image is invalid.
declare function basic:height (
$image as xs:base64Binary
) as xs:unsignedInt external
Returns the height of the passed image.
- $image the image
- the height in pixels
- ierr:IM001 the passed image is invalid.
declare function basic:width (
$image as xs:base64Binary
) as xs:unsignedInt external
Returns the width of the passed image.
- $image the image
- the width in pixels
- ierr:IM001 the passed image is invalid.
