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

View as XML or JSON.

This module provides functions to handle image manipulations like resizing, zooming, special effects etc.

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

Function Summary

add-noise ($image as xs:base64Binary, $noise-type as xs:string) as xs:base64Binary

Add noise to an image.

blur ($image as xs:base64Binary, $radius as xs:int, $sigma as xs:int) as xs:base64Binary external

Blur an image.

charcoal ($image as xs:base64Binary, $radius as xs:double, $sigma as xs:double) as xs:base64Binary external

Apply a charcoal effect to the image (looks like a charcoal sketch).

chop ($image as xs:base64Binary, $upper-left-x as xs:unsignedInt, $upper-left-y as xs:unsignedInt) as xs:base64Binary external

Copy a part of a source image as new image.

contrast ($image as xs:base64Binary, $sharpen as xs:double) as xs:base64Binary external

Contrast an image (enhances image intensity differences) by a given value.

crop ($image as xs:base64Binary, $lower-right-x as xs:unsignedInt, $lower-right-y as xs:unsignedInt) as xs:base64Binary external

Copy a part of a source image as new image.

despeckle ($image as xs:base64Binary) as xs:base64Binary external

Despeckle an image.

edge ($image as xs:base64Binary, $radius as xs:unsignedInt) as xs:base64Binary external

Highlight edges in an image.

emboss ($image as xs:base64Binary, $radius as xs:double, $sigma as xs:double) as xs:base64Binary external

Emboss an images (highlights edges with 3D effect).

enhance ($image as xs:base64Binary) as xs:base64Binary external

Enhance an images (minimizes noise).

equalize ($image as xs:base64Binary) as xs:base64Binary external

Equalize an images (histogramm equalization).

erase ($image as xs:base64Binary) as xs:base64Binary external

Set all pixels of the image to the current backround color.

flip ($image as xs:base64Binary) as xs:base64Binary external

Flip an image (vertical rotation).

flop ($image as xs:base64Binary) as xs:base64Binary external

Flop an image (horizontal rotation).

gamma ($image as xs:base64Binary, $gamma-value as xs:double) as xs:base64Binary external

Gamma correct an image.

gamma ($image as xs:base64Binary, $gamma-red as xs:double, $gamma-green as xs:double, $gamma-blue as xs:double) as xs:base64Binary external

Gamma correct an image for every color channel seperately.

implode ($image as xs:base64Binary, $factor as xs:double) as xs:base64Binary external

Apply an implode effect to an image (a sort of special effect).

oil-paint ($image as xs:base64Binary, $radius as xs:double) as xs:base64Binary external

Apply an oil paint effect to an image (makes the image look as if it was an oil paint).

overlay ($image as xs:base64Binary, $overlay-image as xs:base64Binary, $overlay-upper-left-x as xs:unsignedInt, $overlay-upper-left-y as xs:unsignedInt, $operator as xs:string) as xs:base64Binary

Overlay $image with $overlay-image at the specfied position.

reduce-noise ($image as xs:base64Binary, $order as xs:double) as xs:base64Binary external

Reduce noise of an image using a noise peak elemination filter.

resize ($image as xs:base64Binary, $width as xs:unsignedInt, $height as xs:unsignedInt) as xs:base64Binary external

Get a copy of the passed image with changed width and height (without zooming the image's content).

rotate ($image as xs:base64Binary, $angle as xs:int) as xs:base64Binary external

Get a new image as rotated copy of a passed source image (rotated by -360 to 360 degrees).

solarize ($image as xs:base64Binary, $factor as xs:double) as xs:base64Binary external

Apply a solarize effect to the image (similar to the effect seen when exposing a photographic film to light during the development process).

stereo ($left-image as xs:base64Binary, $right-image as xs:base64Binary) as xs:base64Binary external

Make two passed images appear as stereo image when viewed with red-blue glasses.

sub-image ($image as xs:base64Binary, $left-upper-x as xs:unsignedInt, $left-upper-y as xs:unsignedInt, $width as xs:unsignedInt, $height as xs:unsignedInt) as xs:base64Binary external

Copy a part of the source image specified by a rectangle.

swirl ($image as xs:base64Binary, $degree as xs:double) as xs:base64Binary external

Swirl an image (image pixels are rotated by degree).

transparent ($image as xs:base64Binary, $color as xs:string) as xs:base64Binary

Make all pixels of the specfied color transparent.

trim ($image as xs:base64Binary) as xs:base64Binary external

Trim edges of the image's background color from the image.

watermark ($image as xs:base64Binary, $watermark as xs:base64Binary) as xs:base64Binary external

Add a $watermark image to $image.

zoom-by-height ($image as xs:base64Binary, $height as xs:unsignedInt) as xs:base64Binary external

Zoom the passed image to a given new height while keeping the ratio between width and height.

zoom-by-width ($image as xs:base64Binary, $width as xs:unsignedInt) as xs:base64Binary external

Zoom the passed image to a given new width while keeping the ratio between width and height.

zoom ($image as xs:base64Binary, $ratio as xs:double) as xs:base64Binary external

Zoom the passed image by the specified factor while keeping the ratio between width and height.

Functions

add-noise#2

declare  function man:add-noise($image as xs:base64Binary, $noise-type as xs:string) as xs:base64Binary

Add noise to an image.

Allowed noise types are:

  • UniformNoise
  • GaussianNoise
  • MultiplicativeGaussianNoise
  • ImpulseNoise
  • LaplaceianNoise
  • PoissonNoise

Parameters

image as xs:base64Binary
the source image
noise-type as xs:string
specifies the type of noise to add

Returns

xs:base64Binary
A copy of $image with added noise

blur#3

declare  function man:blur($image as xs:base64Binary, $radius as xs:int, $sigma as xs:int) as xs:base64Binary external

Blur an image.

Parameters

image as xs:base64Binary
the source image
radius as xs:int
is the radius of the Gaussian in pixels.
sigma as xs:int
is the standard deviation of the Laplacian in pixels.

Returns

xs:base64Binary
A blured copy of $image

charcoal#3

declare  function man:charcoal($image as xs:base64Binary, $radius as xs:double, $sigma as xs:double) as xs:base64Binary external

Apply a charcoal effect to the image (looks like a charcoal sketch).

Parameters

image as xs:base64Binary
the source image
radius as xs:double
radius of the Gaussian in pixels
sigma as xs:double
standard deviation of the Laplacian in pixels

Returns

xs:base64Binary
A charcoaled copy of $image

chop#3

declare  function man:chop($image as xs:base64Binary, $upper-left-x as xs:unsignedInt, $upper-left-y as xs:unsignedInt) as xs:base64Binary external

Copy a part of a source image as new image.

The copied part is all right of $upper-left-x and below $upper-left-y.

Parameters

image as xs:base64Binary
source image
upper-left-x as xs:unsignedInt
x position of the upper left corner of the part to copy
upper-left-y as xs:unsignedInt
y position of the upper left corner of the part to copy

Returns

xs:base64Binary
A new image copied from a part of source image

contrast#2

declare  function man:contrast($image as xs:base64Binary, $sharpen as xs:double) as xs:base64Binary external

Contrast an image (enhances image intensity differences) by a given value.

Parameters

image as xs:base64Binary
the source image
sharpen as xs:double
defines how much the image is contrasted.

Returns

xs:base64Binary
A contrasted copy of $image

crop#3

declare  function man:crop($image as xs:base64Binary, $lower-right-x as xs:unsignedInt, $lower-right-y as xs:unsignedInt) as xs:base64Binary external

Copy a part of a source image as new image.

The copied part is all left of $lower-right-x and above $lower-right-y.

Parameters

image as xs:base64Binary
source image
lower-right-x as xs:unsignedInt
x position of the lower right corner of the part to copy
lower-right-y as xs:unsignedInt
y position of the lower right corner of the part to copy

Returns

xs:base64Binary
A new image copied from a part of source image

despeckle#1

declare  function man:despeckle($image as xs:base64Binary) as xs:base64Binary external

Despeckle an image.

Parameters

image as xs:base64Binary
the source image

Returns

xs:base64Binary
A despeckled copy of $image

edge#2

declare  function man:edge($image as xs:base64Binary, $radius as xs:unsignedInt) as xs:base64Binary external

Highlight edges in an image.

Parameters

image as xs:base64Binary
the source image
radius as xs:unsignedInt
radius of the pixel neighborhood (0 for automatic selection)

Returns

xs:base64Binary
An edged copy of $image

emboss#3

declare  function man:emboss($image as xs:base64Binary, $radius as xs:double, $sigma as xs:double) as xs:base64Binary external

Emboss an images (highlights edges with 3D effect).

Parameters

image as xs:base64Binary
the source image
radius as xs:double
radius of the Gaussian in pixels
sigma as xs:double
standard deviation of the Laplacian in pixels

Returns

xs:base64Binary
An embossed copy of $image

enhance#1

declare  function man:enhance($image as xs:base64Binary) as xs:base64Binary external

Enhance an images (minimizes noise).

Parameters

image as xs:base64Binary
the source image

Returns

xs:base64Binary
An enhanced copy of $image.

equalize#1

declare  function man:equalize($image as xs:base64Binary) as xs:base64Binary external

Equalize an images (histogramm equalization).

Parameters

image as xs:base64Binary
the source image

Returns

xs:base64Binary
An equalized copy of $image.

erase#1

declare  function man:erase($image as xs:base64Binary) as xs:base64Binary external

Set all pixels of the image to the current backround color.

In most cases, this will result in all pixels to be set to white.

Parameters

image as xs:base64Binary
image to erase

Returns

xs:base64Binary
A copy of image with all pixels set to the current background color

flip#1

declare  function man:flip($image as xs:base64Binary) as xs:base64Binary external

Flip an image (vertical rotation).

Parameters

image as xs:base64Binary
source image

Returns

xs:base64Binary
A vertically rotated copy of $image

flop#1

declare  function man:flop($image as xs:base64Binary) as xs:base64Binary external

Flop an image (horizontal rotation).

Parameters

image as xs:base64Binary
source image

Returns

xs:base64Binary
A horizontally rotated copy of $image

gamma#2

declare  function man:gamma($image as xs:base64Binary, $gamma-value as xs:double) as xs:base64Binary external

Gamma correct an image.

Gamma values less than zero will erase the image.

Parameters

image as xs:base64Binary
the source image
gamma-value as xs:double
value for which to gamma correct the image

Returns

xs:base64Binary
A gamma corrected copy of $image

gamma#4

declare  function man:gamma($image as xs:base64Binary, $gamma-red as xs:double, $gamma-green as xs:double, $gamma-blue as xs:double) as xs:base64Binary external

Gamma correct an image for every color channel seperately.

Gamma values less than zero for any color will erase the corresponding color.

Parameters

image as xs:base64Binary
the source image
gamma-red as xs:double
value to gamma correct the red channel of the image
gamma-green as xs:double
value to gamma correct the green channel of the image
gamma-blue as xs:double
value to gamma correct the blue channel of the image

Returns

xs:base64Binary
A gamma corrected copy of $image

implode#2

declare  function man:implode($image as xs:base64Binary, $factor as xs:double) as xs:base64Binary external

Apply an implode effect to an image (a sort of special effect).

Parameters

image as xs:base64Binary
the source image
factor as xs:double
factor to implode to

Returns

xs:base64Binary
An imploded copy of $image.

oil-paint#2

declare  function man:oil-paint($image as xs:base64Binary, $radius as xs:double) as xs:base64Binary external

Apply an oil paint effect to an image (makes the image look as if it was an oil paint).

Parameters

image as xs:base64Binary
the source image
radius as xs:double
radius with which to oil paint

Returns

xs:base64Binary
A oil-painted copy of $image

overlay#5

declare  function man:overlay($image as xs:base64Binary, $overlay-image as xs:base64Binary, $overlay-upper-left-x as xs:unsignedInt, $overlay-upper-left-y as xs:unsignedInt, $operator as xs:string) as xs:base64Binary

Overlay $image with $overlay-image at the specfied position.

The $operator defines the details of the overlay and can have one of the following values:

  • OverCompositeOp: The result is the union of the two image shapes with the overlay image obscuring image in the region of overlap.
  • InCompositeOp: The result is a simple overlay image cut by the shape of image. None of the image data of image is included in the result.
  • OutCompositeOp: The resulting image is the overlay image with the shape of image cut out.
  • AtopCompositeOp: The result is the same shape as image, with overlay image obscuring image there the image shapes overlap. Note that this differs from OverCompositeOp because the portion of composite image outside of image's shape does not appear in the result.
  • XorCompositeOp: The result is the image data from both overlay image and image that is outside the overlap region. The overlap region will be blank.
  • PlusCompositeOp: The result is just the sum of the image data of both images. Output values are cropped to 255 (no overflow). This operation is independent of the matte channels.
  • MinusCompositeOp: The result of overlay image - image, with overflow cropped to zero. The matte chanel is ignored (set to 255, full coverage).
  • AddCompositeOp: The result of overlay image + image, with overflow wrapping around (mod 256).
  • SubtractCompositeOp: The result of overlay image - image, with underflow wrapping around (mod 256). The add and subtract operators can be used to perform reverible transformations.
  • DifferenceCompositeOp: The result of abs(overlay image - image). This is useful for comparing two very similar images.
  • BumpmapCompositeOp: The result image shaded by overlay image.

Parameters

image as xs:base64Binary
base image
overlay-image as xs:base64Binary
image to overlay.
overlay-upper-left-x as xs:unsignedInt
horizontal position within $image where the left upper edge of the $overlay-image is placed
overlay-upper-left-y as xs:unsignedInt
vertical position within $image where the left upper edge of the $overlay-image is placed
operator as xs:string
defines how the overlay image should be overlayed (see details in operator listing above)

Returns

xs:base64Binary
A new image consisting of $image overlayed with $overlay-image.

reduce-noise#2

declare  function man:reduce-noise($image as xs:base64Binary, $order as xs:double) as xs:base64Binary external

Reduce noise of an image using a noise peak elemination filter.

Parameters

image as xs:base64Binary
the source image
order as xs:double
defines how much the noise is reduced

Returns

xs:base64Binary
A copy of $image with reduced noise

resize#3

declare  function man:resize($image as xs:base64Binary, $width as xs:unsignedInt, $height as xs:unsignedInt) as xs:base64Binary external

Get a copy of the passed image with changed width and height (without zooming the image's content).

To change the size of the actual contents of an image, use the zoom function.

More in detail: If the new dimensions are greater than the current dimensions the new image will have the passed image in the upper left corner and the rest will be filled with the current background color.

If the passed dimensions are less than the current dimensions, the new image will contain the specified rectangle of the passed image beginning at the upper left corner.

Parameters

image as xs:base64Binary
image to resize
width as xs:unsignedInt
new width
height as xs:unsignedInt
new height

Returns

xs:base64Binary
resized copy of the source image

rotate#2

declare  function man:rotate($image as xs:base64Binary, $angle as xs:int) as xs:base64Binary external

Get a new image as rotated copy of a passed source image (rotated by -360 to 360 degrees).

The image is enlarged if this is required for containing the rotated image, but never shrunk even if the rotation would make a smaller image possible.

Parameters

image as xs:base64Binary
source image.
angle as xs:int
between -360 to 360 degrees. Other values will be adjusted by modulo 360

Returns

xs:base64Binary
A rotated copy of $image

solarize#2

declare  function man:solarize($image as xs:base64Binary, $factor as xs:double) as xs:base64Binary external

Apply a solarize effect to the image (similar to the effect seen when exposing a photographic film to light during the development process).

Parameters

image as xs:base64Binary
the source image
factor as xs:double
strength of the solarization (0 to 65535; 65535=100%)

Returns

xs:base64Binary
A solarized copy of $image.

stereo#2

declare  function man:stereo($left-image as xs:base64Binary, $right-image as xs:base64Binary) as xs:base64Binary external

Make two passed images appear as stereo image when viewed with red-blue glasses.

Both images should be same but from a slightly different angle for this to work.

Both images should have the same size, if not, the size of the left image will be taken.

Parameters

left-image as xs:base64Binary
left image for the stereo image.
right-image as xs:base64Binary
right image for the stereo image.

Returns

xs:base64Binary
A new image as combined stereo image of both source images

sub-image#5

declare  function man:sub-image($image as xs:base64Binary, $left-upper-x as xs:unsignedInt, $left-upper-y as xs:unsignedInt, $width as xs:unsignedInt, $height as xs:unsignedInt) as xs:base64Binary external

Copy a part of the source image specified by a rectangle.

If the passed parameters for the sub-image specify a rectangle that isn't entirely within the source image only the area that lies within the image boundaries will be returned.

Parameters

image as xs:base64Binary
the image from which to extract a sub-image
left-upper-x as xs:unsignedInt
is the x value of the upper left corner of the rectangle to cut out
left-upper-y as xs:unsignedInt
is the y value of the upper left corner of the rectangle to cut out.
width as xs:unsignedInt
width of the rectangle to cut out
height as xs:unsignedInt
height of the rectangle to cut out

Returns

xs:base64Binary
A new image containing parts of the source image

swirl#2

declare  function man:swirl($image as xs:base64Binary, $degree as xs:double) as xs:base64Binary external

Swirl an image (image pixels are rotated by degree).

Parameters

image as xs:base64Binary
the source image
degree as xs:double
degree to swirl image pixels

Returns

xs:base64Binary
A swirled copy of $image

transparent#2

declare  function man:transparent($image as xs:base64Binary, $color as xs:string) as xs:base64Binary

Make all pixels of the specfied color transparent.

This works correctly only with image types supporting transparency (e.g GIF or PNG).

Parameters

image as xs:base64Binary
the source image
color as xs:string
color to make transparent (e.g. '#FFFFFF')

Returns

xs:base64Binary
A copy of $image with the specified color made transparent.

trim#1

declare  function man:trim($image as xs:base64Binary) as xs:base64Binary external

Trim edges of the image's background color from the image.

Parameters

image as xs:base64Binary
the source image

Returns

xs:base64Binary
A trimmed copy of $image

watermark#2

declare  function man:watermark($image as xs:base64Binary, $watermark as xs:base64Binary) as xs:base64Binary external

Add a $watermark image to $image.

Parameters

image as xs:base64Binary
the source image
watermark as xs:base64Binary
the watermark image

Returns

xs:base64Binary
A watermarked copy of $image

zoom-by-height#2

declare  function man:zoom-by-height($image as xs:base64Binary, $height as xs:unsignedInt) as xs:base64Binary external

Zoom the passed image to a given new height while keeping the ratio between width and height.

So, the width is scaled accordingly.

Important note: this function does not change the size information stored in the image (e.g. basic:width will not show a different value).

Parameters

image as xs:base64Binary
image to resize
height as xs:unsignedInt
new height for the image in pixels

Returns

xs:base64Binary
A copy of $image with given $height and width adjusted accordingly

zoom-by-width#2

declare  function man:zoom-by-width($image as xs:base64Binary, $width as xs:unsignedInt) as xs:base64Binary external

Zoom the passed image to a given new width while keeping the ratio between width and height.

So, the height is scaled accordingly.

Important note: this function does not change the size information stored in the image (e.g. basic:width will not show a different value).

Parameters

image as xs:base64Binary
image to resize
width as xs:unsignedInt
new width for the image in pixels

Returns

xs:base64Binary
A copy of $image with given $width and height changed accordingly

zoom#2

declare  function man:zoom($image as xs:base64Binary, $ratio as xs:double) as xs:base64Binary external

Zoom the passed image by the specified factor while keeping the ratio between width and height.

A ratio of less than 1 will make the image smaller.

A ratio of less or equal than 0 will not effect the image.

Important note: this function does not change the size information stored in the image (e.g. basic:width will not show a different value).

Parameters

image as xs:base64Binary
image to resize
ratio as xs:double
ratio to zoom width and height by

Returns

xs:base64Binary
A copy of $image with resized content