MagickWand

class MagickWand : Closeable

MagickWand API. Used to hold the images as well as operate on them.

Constructors

Link copied to clipboard
fun MagickWand()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
external fun adaptiveResizeImage(width: Long, height: Long)

Adaptively resize the currently selected image.

Link copied to clipboard
external fun addImage(addWand: MagickWand)

Adds a clone of the images from the second wand and inserts them into the first wand.

Link copied to clipboard
external fun annotateImage(drawingWand: DrawingWand, x: Double, y: Double, angle: Double, text: String)

Annotates an image with text.

Link copied to clipboard
external fun appendAll(stack: Boolean)

Append the images in a wand from the current image onwards, creating a new wand with the single image result. This is affected by the gravity and background settings of the first image.

Link copied to clipboard
external fun autoOrient(): Boolean

Automatically adjusts the loaded image so that its orientation is suitable for viewing (i.e. top-left orientation).

Link copied to clipboard
external fun blurImage(radius: Double, sigma: Double)

Blurs an image. We convolve the image with a gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and blurImage selects a suitable radius for you.

Link copied to clipboard
fun borderImage(pixelWand: PixelWand, width: Long, height: Long, compose: CompositeOperator)

Surrounds the image with a border of the color defined by the bordercolor pixel wand.

Link copied to clipboard
external fun clearException()

Clear any internal exceptions

Link copied to clipboard
fun clone(): MagickWand

Clone the wand into a new one.

Link copied to clipboard
open override fun close()

This isn't meant to be called manually. You can call destroy instead. This does the same thing as destroy, but it's here to be used with a use{} block for convenience. For example wand.use { }

Link copied to clipboard
fun clutImage(clutWand: MagickWand, method: PixelInterpolateMethod)

Replaces colors in the image from a color lookup table.

Link copied to clipboard
fun compareImages(reference: MagickWand, metric: MetricType): Comparison

Compares two images and returns the distortion and diffImage

Link copied to clipboard
fun compositeImage(sourceWand: MagickWand, compose: CompositeOperator, clipToSelf: Boolean, x: Long, y: Long)

Compose another image onto self at (x,y) using composition_operator

Link copied to clipboard
external fun cropImage(width: Long, height: Long, x: Long, y: Long)

Extract a region of the image. The width and height is used as the size of the region. x and y is the offset.

Link copied to clipboard
external fun destroy()

It's recommended to manually destroy all wands when finished. Otherwise the memory will stay around forever until Magick.terminate

Link copied to clipboard
external fun drawImage(drawingWand: DrawingWand)

Renders the drawing wand on the current image.

Link copied to clipboard
fun evaluateImage(op: EvaluateOperator, value: Double)

Applies an arithmetic, relational, or logical expression to an image. Use these operators to lighten or darken an image, to increase or decrease contrast in an image, or to produce the "negative" of an image.

Link copied to clipboard
external fun exportImagePixels(x: Long, y: Long, width: Long, height: Long, map: String): ByteArray?

Extracts pixel data from an image and returns it to you as a ByteArray.

Link copied to clipboard
external fun extentImage(width: Long, height: Long, x: Long, y: Long)

Extends the image as defined by the geometry, gravity, and wand background color. Set the (x,y) offset of the geometry to move the original wand relative to the extended wand.

Link copied to clipboard
external fun fit(width: Long, height: Long)

Resize the image to fit within the given dimensions, maintaining the current aspect ratio.

Link copied to clipboard
external fun flipImage()

Creates a vertical mirror image by reflecting the pixels around the central x-axis.

Link copied to clipboard
external fun flopImage()

Creates a horizontal mirror image by reflecting the pixels around the central y-axis.

Link copied to clipboard
external fun fx(expression: String)

Evaluate expression for each pixel in the image.

Link copied to clipboard
external fun gaussianBlurImage(radius: Double, sigma: Double)

Blurs an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and gaussianBlurImage selects a suitable radius for you.

Link copied to clipboard
external fun getException(): NativeMagickException

Get the internal exception type and message

Link copied to clipboard
fun getExceptionType(): ExceptionType

Get the type of internal exception

Link copied to clipboard
external fun getImageAlphaChannel(): Boolean

MagickGetImageAlphaChannel() returns MagickFalse if the image alpha channel is not activated. That is, the image is RGB rather than RGBA or CMYK rather than CMYKA.

Link copied to clipboard
external fun getImageColors(): Long

Gets the number of unique colors in the image.

Link copied to clipboard
external fun getImageHeight(): Long

Retrieve the height of the image.

Link copied to clipboard
external fun getImageHistogram(): Array<PixelWand>?

Returns the image histogram as a List of PixelWand instances for every unique color.

Link copied to clipboard
external fun getImagePage(): PageGeometry

Retrieve the PageGeometry (width, height, x offset, y offset) of the image.

Link copied to clipboard
external fun getImagePixelColor(x: Long, y: Long): PixelWand?

Returns a PixelWand instance for the pixel specified by x and y offsets.

Link copied to clipboard
external fun getImageProperty(name: String): String

Retrieve the named image property value.

Link copied to clipboard
external fun getImageResolution(): Resolution

Returns the image resolution (horizontal resolution, vertical resolution).

Link copied to clipboard
external fun getImageWidth(): Long

Retrieve the width of the image.

Link copied to clipboard
external fun haldClutImage(haldWand: MagickWand)

Replaces colors in the image from a Hald color lookup table. A Hald color lookup table is a 3-dimensional color cube mapped to 2 dimensions. Create it with the HALD coder. You can apply any color transformation to the Hald image and then use this method to apply the transform to the image.

Link copied to clipboard
fun implode(amount: Double, method: PixelInterpolateMethod)

Implodes the image towards the center by the specified percentage.

Link copied to clipboard
external fun importImagePixels(x: Long, y: Long, columns: UInt, rows: UInt, pixels: ByteArray)

Accepts pixel datand stores it in the image at the location you specify. The method returns MagickTrue on success otherwise MagickFalse if an error is encountered. The pixel data can be either char, short int, int, ssize_t, float, or double in the order specified by map.

Link copied to clipboard
external fun isWand(): Boolean

Check to see if this is still the correct wand.

Link copied to clipboard
external fun kMeans(numberOfColors: Long, maxIterations: Long, tolerance: Double)

Applies k-means color reduction to the image.

Link copied to clipboard
external fun labelImage(label: String)

Adds a label to your image.

Link copied to clipboard
external fun levelImage(blackPoint: Double, gamma: Double, whitePoint: Double)

Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.

Link copied to clipboard
external fun liquidRescaleImage(width: Long, height: Long, deltaX: Double, rigidity: Double)

Rescale the image using seam carving algorithm.

Link copied to clipboard
external fun modulateImage(brightness: Double, saturation: Double, hue: Double)

Control the brightness, saturation, and hue of an image

Link copied to clipboard
external fun negateImage()

Negates the colors in the reference image. The Grayscale option means that only grayscale values within the image are negated.

Link copied to clipboard
fun newImage(width: Long, height: Long)

Adds a blank image canvas of the specified size to the wand. Background color is pre-set to transparent.

external fun newImage(width: Long, height: Long, background: PixelWand)
fun newImage(width: Long, height: Long, background: String)

Adds a blank image canvas of the specified size and background color to the wand.

Link copied to clipboard
external fun nextImage()

Sets the next image in the wand as the current image.

Link copied to clipboard
external fun pingImage(path: String)

Is the same as readImage except the only valid information returned is the image width, height, size, and format. It is designed to efficiently obtain this information from a file without reading the entire image sequence into memory.

Link copied to clipboard
external fun pingImageBlob(blob: ByteArray)

Pings an image or image sequence from a blob.

Link copied to clipboard
external fun profileImage(name: String, profile: ByteArray?)

Adds or removes an ICC, IPTC, or generic profile from an image. If the profile is null, it is removed from the image otherwise added. Use a name of '*' and a profile of null to remove all profiles from the image.

Link copied to clipboard
fun quantizeImage(numberOfColors: Long, colorspace: ColorspaceType, treeDepth: Long, ditherMethod: DitherMethod, measureError: Boolean)

Reduce the number of colors in the image.

Link copied to clipboard
fun quantizeImages(numberOfColors: Long, colorspace: ColorspaceType, treeDepth: Long, ditherMethod: DitherMethod, measureError: Boolean)

Reduce the number of colors in the image.

Link copied to clipboard
external fun readImage(path: String)

Reads an image or image sequence. The images are inserted just before the current image pointer position.

Link copied to clipboard
external fun readImageBlob(blob: ByteArray)

Reads an image or image sequence from a blob. In all other respects it is like readImage.

Link copied to clipboard
external fun requiresOrientation(): Boolean

Detect if the loaded image is not in top-left orientation, and hence should be "auto" oriented, so it is suitable for viewing.

Link copied to clipboard
fun resampleImage(x: Double, y: Double, filter: FilterType)

Resample the image to the specified (horizontal) x and (vertical) y resolution, using the specified filter type.

Link copied to clipboard
external fun resetImagePage(pageGeometry: String)

Reset the Wand page canvas and position.

Link copied to clipboard
fun resizeImage(width: Long, height: Long, filter: FilterType)

Resize the image to the specified width and height, using the specified filter type.

Link copied to clipboard
external fun rotateImage(background: PixelWand, degrees: Double)

Rotate the currently selected image by the given number of degrees, filling any empty space with the background color of a given PixelWand.

Link copied to clipboard
external fun sampleImage(width: Long, height: Long)

Sample the image to the target resolution

Link copied to clipboard
external fun sepiaToneImage(threshold: Double)

Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning. threshold ranges from 0 to QuantumRange and is a measure of the extent of the sepia toning. A threshold of 80 is a good starting point for a reasonable tone.

Link copied to clipboard
external fun setBackgroundColor(background: PixelWand)

Set the background color.

Link copied to clipboard
external fun setFirstIterator()

Sets the wand iterator to the first image.

Link copied to clipboard
external fun setImageAlpha(alpha: Double)

Sets the image to the specified alpha level.

Link copied to clipboard
fun setImageAlphaChannel(alphaChannel: AlphaChannelOption)

Set the image alpha channel mode.

Link copied to clipboard
external fun setImageBackgroundColor(background: PixelWand)

Set the image background color.

Link copied to clipboard
fun setImageChannelMask(mask: ChannelType): ChannelType

Sets image channel mask.

Link copied to clipboard
external fun setImageProperty(name: String, value: String)

Set the named image property.

Link copied to clipboard
external fun setImageResolution(x: Double, y: Double)

Sets the image (horizontal) x and (vertical) y resolution.

Link copied to clipboard
external fun setOption(key: String, value: String)

Associates one or options with the wand (e.g. setOption("jpeg:perserve","yes")).

Link copied to clipboard
external fun setResolution(x: Double, y: Double)

Sets the wand (horizontal) x and (vertical) y resolution.

Link copied to clipboard
fun setResourceLimit(type: ResourceType, limit: Long)

The limit for a particular resource.

Link copied to clipboard
external fun setSamplingFactors(samplingFactors: DoubleArray)

Sets the image sampling factors.

Link copied to clipboard
external fun setSize(columns: Long, rows: Long)

Sets the size of the MagickWand. Set it before you read a raw image format such as RGB, GRAY, or CMYK.

Link copied to clipboard
external fun shadowImage(alpha: Double, Sigma: Double, x: Long, y: Long)

Simulates an image shadow.

Link copied to clipboard
external fun sharpenImage(radius: Double, sigma: Double)

Sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and sharpenImage selects a suitable radius for you.

Link copied to clipboard
external fun stripImage()

Strips an image of all profiles and comments.

Link copied to clipboard
external fun thumbnailImage(width: Long, height: Long)

Changes the size of an image to the given dimensions and removes any associated profiles. The goal is to produce small low cost thumbnail images suited for display on the Web.

Link copied to clipboard
fun transformImageColorspace(colorspace: ColorspaceType)

Set the image colorspace, transforming (unlike imageColorspace) image data in the process.

Link copied to clipboard
external fun trimImage(fuzz: Double)

Trim the image removing the backround color from the edges.

Link copied to clipboard
external fun uniqueImageColors()

Discard all but one of any pixel color.

Link copied to clipboard
external fun writeImage(path: String)

Write the current image to the provided path.

Link copied to clipboard
external fun writeImageBlob(format: String): ByteArray

Write the image in the desired format to a new blob.

Link copied to clipboard
external fun writeImages(path: String, adjoin: Boolean)

Writes an image or image sequence.

Link copied to clipboard
external fun writeImagesBlob(format: String): ByteArray

Write the images in the desired format to a new blob.

Properties

Link copied to clipboard
var colorspace: ColorspaceType

The wand colorspace type.

Link copied to clipboard
var compression: CompressionType

The wand compression type.

Link copied to clipboard
var compressionQuality: Long

The wand compression quality.

Link copied to clipboard
var filename: String

The filename associated with an image sequence.

Link copied to clipboard
var font: String

The font associated with the MagickWand.

Link copied to clipboard
var format: String

The format of the MagickWand.

Link copied to clipboard
var gravity: GravityType

The gravity type.

Link copied to clipboard
val id: ULong

The unique id of the wand.

Link copied to clipboard
var imageColorspace: ColorspaceType

The image colorspace. Setting does not modify the image data.

Link copied to clipboard
var imageCompose: CompositeOperator

The image composite operator, useful for specifying how to composite the image thumbnail when using the montageImage method.

Link copied to clipboard
var imageCompression: CompressionType

The image compression.

Link copied to clipboard
var imageCompressionQuality: Long

The image compression quality.

Link copied to clipboard
var imageDelay: Long

The image delay.

Link copied to clipboard
var imageDepth: Long

The image depth.

Link copied to clipboard
var imageDispose: DisposeType

The image disposal method.

Link copied to clipboard
var imageEndian: EndianType

The image endian method.

Link copied to clipboard
var imageFilename: String

The filename of a particular image in a sequence.

Link copied to clipboard
var imageFormat: String

The format of a particular image in a sequence.

Link copied to clipboard
var imageFuzz: Double

The image fuzz.

Link copied to clipboard
var imageGamma: Double

Gets the image gamma.

Link copied to clipboard
var imageGravity: GravityType

The image gravity type.

Link copied to clipboard
var imageInterlaceScheme: InterlaceType

The image interlace scheme.

Link copied to clipboard
var imageInterpolateMethod: PixelInterpolateMethod

The interpolation method for the specified image.

Link copied to clipboard
var imageIterations: Long

The image iterations. The image delay is set in 1/100th of a second.

Link copied to clipboard
var imageOrientation: OrientationType

The image orientaiton.

Link copied to clipboard
var imageRenderingIntent: RenderingIntent

Image rendering intent.

Link copied to clipboard
var imageScene: Long

The image scene.

Link copied to clipboard
var imageType: ImageType

The potential image type.

Link copied to clipboard
var imageUnits: ResolutionType

The image units of resolution.

Link copied to clipboard
var interlaceScheme: InterlaceType

The image interlace scheme.

Link copied to clipboard
var interpolateMethod: PixelInterpolateMethod

The image interpolate pixel method.

Link copied to clipboard
val isInitialized: Boolean

Check to see if this is initialized with the underlying C obj.

Link copied to clipboard
var iteratorIndex: Long

The position of the iterator in the image list.

Link copied to clipboard
var orientation: OrientationType

Wand orientation type.

Link copied to clipboard
var pointsize: Double

The font pointsize associated with the MagickWand.

Link copied to clipboard
var type: ImageType

The MagickWand image type attribute.