pub struct MagickWand { /* private fields */ }
Implementations§
Source§impl MagickWand
impl MagickWand
pub fn new() -> Self
pub fn clear_exception(&mut self) -> Result<(), MagickError>
pub fn get_exception_type(&self) -> ExceptionType
pub fn get_exception(&self) -> Result<(String, ExceptionType), MagickError>
pub fn is_wand(&self) -> Result<(), MagickError>
Source§impl MagickWand
MagickWand is a Rustic wrapper to the Rust bindings to ImageMagick.
impl MagickWand
MagickWand is a Rustic wrapper to the Rust bindings to ImageMagick.
Instantiating a MagickWand
will construct an ImageMagick “wand”
on which operations can be performed via the MagickWand
functions.
When the MagickWand
is dropped, the ImageMagick wand will be
destroyed as well.
Sourcepub fn new_from_image(img: &Image<'_>) -> Result<MagickWand, MagickError>
pub fn new_from_image(img: &Image<'_>) -> Result<MagickWand, MagickError>
Creates new wand by cloning the image.
img
: the image.
pub fn new_image( &self, columns: usize, rows: usize, background: &PixelWand, ) -> Result<(), MagickError>
Sourcepub fn set_resource_limit(
resource: ResourceType,
limit: u64,
) -> Result<(), MagickError>
pub fn set_resource_limit( resource: ResourceType, limit: u64, ) -> Result<(), MagickError>
opt-in platforms that have resource limits support
pub fn set_option(&mut self, key: &str, value: &str) -> Result<(), MagickError>
pub fn annotate_image( &mut self, drawing_wand: &DrawingWand, x: f64, y: f64, angle: f64, text: &str, ) -> Result<(), MagickError>
Sourcepub fn add_image(&mut self, other_wand: &MagickWand) -> Result<(), MagickError>
pub fn add_image(&mut self, other_wand: &MagickWand) -> Result<(), MagickError>
Add all images from another wand to this wand at the current index.
pub fn append_all(&mut self, stack: bool) -> Result<MagickWand, MagickError>
pub fn label_image(&self, label: &str) -> Result<(), MagickError>
pub fn write_images(&self, path: &str, adjoin: bool) -> Result<(), MagickError>
Sourcepub fn read_image(&self, path: &str) -> Result<(), MagickError>
pub fn read_image(&self, path: &str) -> Result<(), MagickError>
Read the image data from the named file.
Sourcepub fn read_image_blob<T: AsRef<[u8]>>(
&self,
data: T,
) -> Result<(), MagickError>
pub fn read_image_blob<T: AsRef<[u8]>>( &self, data: T, ) -> Result<(), MagickError>
Read the image data from the vector of bytes.
Sourcepub fn ping_image(&self, path: &str) -> Result<(), MagickError>
pub fn ping_image(&self, path: &str) -> Result<(), MagickError>
Same as read_image, but reads only the width, height, size and format of an image, without reading data.
Sourcepub fn ping_image_blob<T: AsRef<[u8]>>(
&self,
data: T,
) -> Result<(), MagickError>
pub fn ping_image_blob<T: AsRef<[u8]>>( &self, data: T, ) -> Result<(), MagickError>
Same as read_image, but reads only the width, height, size and format of an image, without reading data.
Sourcepub fn merge_image_layers(
&self,
method: LayerMethod,
) -> Result<MagickWand, MagickError>
pub fn merge_image_layers( &self, method: LayerMethod, ) -> Result<MagickWand, MagickError>
Composes all the image layers from the current given image onward to produce a single image of the merged layers.
The inital canvas’s size depends on the given LayerMethod, and is initialized using the first images background color. The images are then composited onto that image in sequence using the given composition that has been assigned to each individual image.
-
method
: the method of selecting the size of the initial canvas. MergeLayer: Merge all layers onto a canvas just large enough to hold all the actual images. The virtual canvas of the first image is preserved but otherwise ignored.FlattenLayer: Use the virtual canvas size of first image. Images which fall outside this canvas is clipped. This can be used to ‘fill out’ a given virtual canvas.
MosaicLayer: Start with the virtual canvas of the first image, enlarging left and right edges to contain all images. Images with negative offsets will be clipped.
Sourcepub fn get_number_images(&self) -> usize
pub fn get_number_images(&self) -> usize
Returns the number of images associated with a magick wand.
Sourcepub fn compare_images(
&self,
reference: &MagickWand,
metric: MetricType,
) -> (f64, Option<MagickWand>)
pub fn compare_images( &self, reference: &MagickWand, metric: MetricType, ) -> (f64, Option<MagickWand>)
Compare two images and return tuple (distortion, diffImage)
diffImage
is None
if distortion == 0
Sourcepub fn compose_images(
&self,
reference: &MagickWand,
composition_operator: CompositeOperator,
clip_to_self: bool,
x: isize,
y: isize,
) -> Result<(), MagickError>
pub fn compose_images( &self, reference: &MagickWand, composition_operator: CompositeOperator, clip_to_self: bool, x: isize, y: isize, ) -> Result<(), MagickError>
Compose another image onto self at (x, y) using composition_operator
Sourcepub fn compose_images_gravity(
&self,
reference: &MagickWand,
composition_operator: CompositeOperator,
gravity_type: GravityType,
) -> Result<(), MagickError>
pub fn compose_images_gravity( &self, reference: &MagickWand, composition_operator: CompositeOperator, gravity_type: GravityType, ) -> Result<(), MagickError>
Compose another image onto self with gravity using composition_operator
Sourcepub fn coalesce(&mut self) -> Result<MagickWand, MagickError>
pub fn coalesce(&mut self) -> Result<MagickWand, MagickError>
Rebuilds image sequence with each frame size the same as first frame, and composites each frame atop of previous. Only affects GIF, and other formats with multiple pages/layers.
Sourcepub fn clut_image(
&self,
clut_wand: &MagickWand,
method: PixelInterpolateMethod,
) -> Result<(), MagickError>
pub fn clut_image( &self, clut_wand: &MagickWand, method: PixelInterpolateMethod, ) -> Result<(), MagickError>
Replaces colors in the image from a color lookup table.
pub fn hald_clut_image(&self, clut_wand: &MagickWand) -> Result<(), MagickError>
pub fn fx(&mut self, expression: &str) -> Result<MagickWand, MagickError>
pub fn set_size(&self, columns: usize, rows: usize) -> Result<(), MagickError>
Sourcepub fn level_image(
&self,
black_point: f64,
gamma: f64,
white_point: f64,
) -> Result<(), MagickError>
pub fn level_image( &self, black_point: f64, gamma: f64, white_point: f64, ) -> Result<(), MagickError>
Level an image. Black and white points are multiplied with QuantumRange to decrease dependencies on the end user.
Sourcepub fn levelize_image(
&self,
black_point: f64,
gamma: f64,
white_point: f64,
) -> Result<(), MagickError>
pub fn levelize_image( &self, black_point: f64, gamma: f64, white_point: f64, ) -> Result<(), MagickError>
Applies the reversed level_image. It compresses the full range of color values, so that they lie between the given black and white points. Gamma is applied before the values are mapped. It can be used to de-contrast a greyscale image to the exact levels specified.
Sourcepub fn normalize_image(&self) -> Result<(), MagickError>
pub fn normalize_image(&self) -> Result<(), MagickError>
MagickNormalizeImage enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available
Sourcepub fn ordered_dither_image(
&self,
threshold_map: &str,
) -> Result<(), MagickError>
pub fn ordered_dither_image( &self, threshold_map: &str, ) -> Result<(), MagickError>
MagickOrderedDitherImage performs an ordered dither based on a number of pre-defined dithering threshold maps, but over multiple intensity levels, which can be different for different channels, according to the input arguments.
Sourcepub fn sigmoidal_contrast_image(
&self,
sharpen: bool,
strength: f64,
midpoint: f64,
) -> Result<(), MagickError>
pub fn sigmoidal_contrast_image( &self, sharpen: bool, strength: f64, midpoint: f64, ) -> Result<(), MagickError>
Apply sigmoidal contrast to the image
Adjusts the contrast of an image with a non-linear sigmoidal contrast algorithm. Increase
the contrast of the image using a sigmoidal transfer function without saturating highlights
or shadows. Contrast indicates how much to increase the contrast (0 is none; 3 is typical;
20 is pushing it); mid-point indicates where midtones fall in the resultant image (0.0 is
white; 0.5 is middle-gray; 1.0 is black). Set sharpen to true
to increase the image
contrast otherwise the contrast is reduced.
sharpen
: increase or decrease image contraststrength
: strength of the contrast, the larger the number the more ‘threshold-like’ it becomes.midpoint
: midpoint of the function as a number in range [0, 1]
Sourcepub fn extend_image(
&self,
width: usize,
height: usize,
x: isize,
y: isize,
) -> Result<(), MagickError>
pub fn extend_image( &self, width: usize, height: usize, x: isize, y: isize, ) -> Result<(), MagickError>
Extend 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.
pub fn profile_image<'a, T: Into<Option<&'a [u8]>>>( &self, name: &str, profile: T, ) -> Result<(), MagickError>
pub fn strip_image(&self) -> Result<(), MagickError>
pub fn flip_image(&self) -> Result<(), MagickError>
pub fn negate_image(&self) -> Result<(), MagickError>
pub fn flop_image(&self) -> Result<(), MagickError>
pub fn blur_image(&self, radius: f64, sigma: f64) -> Result<(), MagickError>
pub fn gaussian_blur_image( &self, radius: f64, sigma: f64, ) -> Result<(), MagickError>
Sourcepub fn statistic_image(
&self,
statistic_type: StatisticType,
width: usize,
height: usize,
) -> Result<(), MagickError>
pub fn statistic_image( &self, statistic_type: StatisticType, width: usize, height: usize, ) -> Result<(), MagickError>
Replace each pixel with corresponding statistic from the neighborhood of the specified width and height.
statistic_type
: the statistic type (e.g.StatisticType::Median
,StatisticType::Mode
, etc.).width
: the width of the pixel neighborhood.height
: the height of the pixel neighborhood.
Sourcepub fn median_blur_image(
&self,
width: usize,
height: usize,
) -> Result<(), MagickError>
pub fn median_blur_image( &self, width: usize, height: usize, ) -> Result<(), MagickError>
Calculate median for each pixel’s neighborhood.
See statistic_image
Sourcepub fn adaptive_resize_image(
&self,
width: usize,
height: usize,
) -> Result<(), MagickError>
pub fn adaptive_resize_image( &self, width: usize, height: usize, ) -> Result<(), MagickError>
Adaptively resize the currently selected image.
Sourcepub fn rotate_image(
&self,
background: &PixelWand,
degrees: f64,
) -> Result<(), MagickError>
pub fn rotate_image( &self, background: &PixelWand, degrees: f64, ) -> Result<(), MagickError>
Rotate the currently selected image by the given number of degrees, filling any empty space with the background color of a given PixelWand
Sourcepub fn trim_image(&self, fuzz: f64) -> Result<(), MagickError>
pub fn trim_image(&self, fuzz: f64) -> Result<(), MagickError>
Trim the image removing the backround color from the edges.
Sourcepub fn get_image_width(&self) -> usize
pub fn get_image_width(&self) -> usize
Retrieve the width of the image.
Sourcepub fn get_image_height(&self) -> usize
pub fn get_image_height(&self) -> usize
Retrieve the height of the image.
Sourcepub fn get_image_page(&self) -> (usize, usize, isize, isize)
pub fn get_image_page(&self) -> (usize, usize, isize, isize)
Retrieve the page geometry (width, height, x offset, y offset) of the image.
Sourcepub fn reset_image_page(&self, page_geometry: &str) -> Result<(), MagickError>
pub fn reset_image_page(&self, page_geometry: &str) -> Result<(), MagickError>
Reset the Wand page canvas and position.
Sourcepub fn get_image_artifact(&self, artifact: &str) -> Result<String, MagickError>
pub fn get_image_artifact(&self, artifact: &str) -> Result<String, MagickError>
Returns a value associated with the specified artifact.
artifact
: the artifact.
pub fn get_image_artifacts( &self, pattern: &str, ) -> Result<Vec<String>, MagickError>
Sourcepub fn set_image_artifact(
&mut self,
artifact: &str,
value: &str,
) -> Result<(), MagickError>
pub fn set_image_artifact( &mut self, artifact: &str, value: &str, ) -> Result<(), MagickError>
Sets a key-value pair in the image artifact namespace. Artifacts differ from properties. Properties are public and are generally exported to an external image format if the format supports it. Artifacts are private and are utilized by the internal ImageMagick API to modify the behavior of certain algorithms.
artifact
: the artifact.value
: the value.
§Example
This example shows how you can blend an image with its blurred copy with 50% opacity by
setting “compose:args” to “50”. This is equivalent to having -define compose:args=50
when
using imagemagick cli.
use magick_rust::{MagickWand, PixelWand, CompositeOperator};
fn main() -> Result<(), magick_rust::MagickError> {
let mut wand1 = MagickWand::new();
wand1.new_image(4, 4, &PixelWand::new())?; // Replace with `read_image` to open your image file
let wand2 = wand1.clone();
wand1.median_blur_image(10, 10)?;
wand1.set_image_artifact("compose:args", "50")?;
wand1.compose_images(&wand2, CompositeOperator::Blend, false, 0, 0)?;
Ok(())
}
Sourcepub fn delete_image_artifact(
&mut self,
artifact: &str,
) -> Result<(), MagickError>
pub fn delete_image_artifact( &mut self, artifact: &str, ) -> Result<(), MagickError>
Deletes a wand artifact.
artifact
: the artifact.
Sourcepub fn get_image_property(&self, name: &str) -> Result<String, MagickError>
pub fn get_image_property(&self, name: &str) -> Result<String, MagickError>
Retrieve the named image property value.
pub fn get_image_properties( &self, pattern: &str, ) -> Result<Vec<String>, MagickError>
Sourcepub fn set_image_property(
&self,
name: &str,
value: &str,
) -> Result<(), MagickError>
pub fn set_image_property( &self, name: &str, value: &str, ) -> Result<(), MagickError>
Set the named image property.
Sourcepub fn get_image_pixel_color(&self, x: isize, y: isize) -> Option<PixelWand>
pub fn get_image_pixel_color(&self, x: isize, y: isize) -> Option<PixelWand>
Returns a PixelWand
instance for the pixel specified by x and y offests.
Sourcepub fn set_sampling_factors(
&self,
samplingFactors: &[f64],
) -> Result<(), MagickError>
pub fn set_sampling_factors( &self, samplingFactors: &[f64], ) -> Result<(), MagickError>
Sets the image sampling factors.
samplingFactors: An array of floats representing the sampling factor for each color component (in RGB order).
Sourcepub fn get_image_histogram(&self) -> Option<Vec<PixelWand>>
pub fn get_image_histogram(&self) -> Option<Vec<PixelWand>>
Returns the image histogram as a vector of PixelWand
instances for every unique color.
Sourcepub fn sharpen_image(&self, radius: f64, sigma: f64) -> Result<(), MagickError>
pub fn sharpen_image(&self, radius: f64, sigma: f64) -> Result<(), MagickError>
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.
radius: the radius of the Gaussian, in pixels, not counting the center pixel.
sigma: the standard deviation of the Gaussian, in pixels.
Sourcepub fn set_background_color(
&self,
pixel_wand: &PixelWand,
) -> Result<(), MagickError>
pub fn set_background_color( &self, pixel_wand: &PixelWand, ) -> Result<(), MagickError>
Set the background color.
Sourcepub fn set_image_background_color(
&self,
pixel_wand: &PixelWand,
) -> Result<(), MagickError>
pub fn set_image_background_color( &self, pixel_wand: &PixelWand, ) -> Result<(), MagickError>
Set the image background color.
Sourcepub fn get_image_resolution(&self) -> Result<(f64, f64), MagickError>
pub fn get_image_resolution(&self) -> Result<(f64, f64), MagickError>
Returns the image resolution as a pair (horizontal resolution, vertical resolution)
Sourcepub fn set_image_resolution(
&self,
x_resolution: f64,
y_resolution: f64,
) -> Result<(), MagickError>
pub fn set_image_resolution( &self, x_resolution: f64, y_resolution: f64, ) -> Result<(), MagickError>
Sets the image resolution
Sourcepub fn set_resolution(
&self,
x_resolution: f64,
y_resolution: f64,
) -> Result<(), MagickError>
pub fn set_resolution( &self, x_resolution: f64, y_resolution: f64, ) -> Result<(), MagickError>
Sets the wand resolution
Sourcepub fn sepia_tone_image(&self, threshold: f64) -> Result<(), MagickError>
pub fn sepia_tone_image(&self, threshold: f64) -> Result<(), MagickError>
Returns the image resolution as a pair (horizontal resolution, vertical resolution)
Sourcepub fn export_image_pixels(
&self,
x: isize,
y: isize,
width: usize,
height: usize,
map: &str,
) -> Option<Vec<u8>>
pub fn export_image_pixels( &self, x: isize, y: isize, width: usize, height: usize, map: &str, ) -> Option<Vec<u8>>
Extracts pixel data from the image as a vector of 0..255 values defined by map
.
See https://imagemagick.org/api/magick-image.php#MagickExportImagePixels for more information.
pub fn export_image_pixels_double( &self, x: isize, y: isize, width: usize, height: usize, map: &str, ) -> Option<Vec<f64>>
Sourcepub fn resize_image(
&self,
width: usize,
height: usize,
filter: FilterType,
) -> Result<(), MagickError>
pub fn resize_image( &self, width: usize, height: usize, filter: FilterType, ) -> Result<(), MagickError>
Resize the image to the specified width and height, using the specified filter type.
Sourcepub fn scale_image(
&self,
width_scale: f64,
height_scale: f64,
filter: FilterType,
) -> Result<(), MagickError>
pub fn scale_image( &self, width_scale: f64, height_scale: f64, filter: FilterType, ) -> Result<(), MagickError>
Resize image by specifying the new size in percent of last size.
Effectively resizes image to (current width * width_scale
, current height *
height_scale
)
Sourcepub fn thumbnail_image(
&self,
width: usize,
height: usize,
) -> Result<(), MagickError>
pub fn thumbnail_image( &self, width: usize, height: usize, ) -> Result<(), MagickError>
Resize the image to the specified width and height, using the ‘thumbnail’ optimizations which remove a lot of image meta-data with the goal of producing small low cost images suited for display on the web.
Sourcepub fn crop_image(
&self,
width: usize,
height: usize,
x: isize,
y: isize,
) -> Result<(), MagickError>
pub fn crop_image( &self, width: usize, height: usize, x: isize, y: isize, ) -> Result<(), MagickError>
Extract a region of the image. The width and height is used as the size of the region. X and Y is the offset.
Sourcepub fn sample_image(
&self,
width: usize,
height: usize,
) -> Result<(), MagickError>
pub fn sample_image( &self, width: usize, height: usize, ) -> Result<(), MagickError>
Sample the image to the target resolution
This is incredibly fast, as it does 1-1 pixel mapping for downscales, and box filtering for upscales
Sourcepub fn resample_image(
&self,
x_resolution: f64,
y_resolution: f64,
filter: FilterType,
) -> Result<(), MagickError>
pub fn resample_image( &self, x_resolution: f64, y_resolution: f64, filter: FilterType, ) -> Result<(), MagickError>
Resample the image to the specified horizontal and vertical resolution, using the specified filter type.
Sourcepub fn liquid_rescale_image(
&self,
width: usize,
height: usize,
delta_x: f64,
rigidity: f64,
) -> Result<(), MagickError>
pub fn liquid_rescale_image( &self, width: usize, height: usize, delta_x: f64, rigidity: f64, ) -> Result<(), MagickError>
Rescale the image using seam carving algorithm
Sourcepub fn implode(
&self,
amount: f64,
method: PixelInterpolateMethod,
) -> Result<(), MagickError>
pub fn implode( &self, amount: f64, method: PixelInterpolateMethod, ) -> Result<(), MagickError>
Implodes the image towards the center by the specified percentage
Sourcepub fn fit(&self, width: usize, height: usize)
pub fn fit(&self, width: usize, height: usize)
Resize the image to fit within the given dimensions, maintaining the current aspect ratio.
Sourcepub fn requires_orientation(&self) -> bool
pub fn requires_orientation(&self) -> bool
Detect if the loaded image is not in top-left orientation, and hence should be “auto” oriented so it is suitable for viewing.
Sourcepub fn auto_orient(&self) -> bool
pub fn auto_orient(&self) -> bool
Automatically adjusts the loaded image so that its orientation is suitable for viewing (i.e. top-left orientation).
Returns true
if successful or false
if an error occurred.
Sourcepub fn write_image(&self, path: &str) -> Result<(), MagickError>
pub fn write_image(&self, path: &str) -> Result<(), MagickError>
Write the current image to the provided path.
Sourcepub fn write_image_blob(&self, format: &str) -> Result<Vec<u8>, MagickError>
pub fn write_image_blob(&self, format: &str) -> Result<Vec<u8>, MagickError>
Write the image in the desired format to a new blob.
The format
argument may be any ImageMagick supported image
format (e.g. GIF, JPEG, PNG, etc).
Sourcepub fn write_images_blob(&self, format: &str) -> Result<Vec<u8>, MagickError>
pub fn write_images_blob(&self, format: &str) -> Result<Vec<u8>, MagickError>
Write the images in the desired format to a new blob.
The format
argument may be any ImageMagick supported image
format (e.g. GIF, JPEG, PNG, etc).
Sourcepub fn get_image_alpha_channel(&self) -> bool
pub fn get_image_alpha_channel(&self) -> bool
Return false if the image alpha channel is not activated. That is, the image is RGB rather than RGBA or CMYK rather than CMYKA
Sourcepub fn draw_image(
&mut self,
drawing_wand: &DrawingWand,
) -> Result<(), MagickError>
pub fn draw_image( &mut self, drawing_wand: &DrawingWand, ) -> Result<(), MagickError>
Renders the drawing wand on the current image
Sourcepub fn deskew_image(&mut self, threshold: f64) -> Result<(), MagickError>
pub fn deskew_image(&mut self, threshold: f64) -> Result<(), MagickError>
Removes skew from the image. Skew is an artifact that occurs in scanned images because of the camera being misaligned, imperfections in the scanning or surface, or simply because the paper was not placed completely flat when scanned
Sourcepub fn set_image_mask(
&mut self,
pixel_mask: PixelMask,
clip_mask: &MagickWand,
) -> Result<(), MagickError>
pub fn set_image_mask( &mut self, pixel_mask: PixelMask, clip_mask: &MagickWand, ) -> Result<(), MagickError>
Sets image clip mask.
pixel_mask
: type of mask, Read or Write.clip_mask
: the clip_mask wand.
Sourcepub fn set_image_channel_mask(&mut self, option: ChannelType) -> ChannelType
pub fn set_image_channel_mask(&mut self, option: ChannelType) -> ChannelType
Set image channel mask
Sourcepub fn evaluate_image(
&mut self,
op: MagickEvaluateOperator,
val: f64,
) -> Result<(), MagickError>
pub fn evaluate_image( &mut self, op: MagickEvaluateOperator, val: f64, ) -> Result<(), MagickError>
Apply 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.
Sourcepub fn border_image(
&self,
pixel_wand: &PixelWand,
width: usize,
height: usize,
compose: CompositeOperator,
) -> Result<(), MagickError>
pub fn border_image( &self, pixel_wand: &PixelWand, width: usize, height: usize, compose: CompositeOperator, ) -> Result<(), MagickError>
Surround the image with a border of the color defined
by the pixel_wand
.
Sourcepub fn shadow_image(
&self,
alpha: f64,
sigma: f64,
x: isize,
y: isize,
) -> Result<(), MagickError>
pub fn shadow_image( &self, alpha: f64, sigma: f64, x: isize, y: isize, ) -> Result<(), MagickError>
Simulate an image shadow
Sourcepub fn import_image_pixels(
&mut self,
x: isize,
y: isize,
columns: usize,
rows: usize,
pixels: &[u8],
map: &str,
) -> Result<(), MagickError>
pub fn import_image_pixels( &mut self, x: isize, y: isize, columns: usize, rows: usize, pixels: &[u8], map: &str, ) -> Result<(), MagickError>
Accepts pixel data and stores it in the image at the location you specify. See https://imagemagick.org/api/magick-image.php#MagickImportImagePixels for more information.
pub fn import_image_pixels_double( &mut self, x: isize, y: isize, columns: usize, rows: usize, pixels: &[f64], map: &str, ) -> Result<(), MagickError>
Sourcepub fn set_first_iterator(&self)
pub fn set_first_iterator(&self)
Set the wand iterator to the first image. See https://imagemagick.org/api/magick-wand.php#MagickSetFirstIterator for more information.
Sourcepub fn next_image(&self) -> bool
pub fn next_image(&self) -> bool
Set the next image in the wand as the current image. See https://imagemagick.org/api/magick-image.php#MagickNextImage for more information.
Sourcepub fn auto_threshold(
&self,
method: AutoThresholdMethod,
) -> Result<(), MagickError>
pub fn auto_threshold( &self, method: AutoThresholdMethod, ) -> Result<(), MagickError>
Automatically performs threshold method to reduce grayscale data down to a binary black & white image. Included algorithms are Kapur, Otsu, and Triangle methods. See https://imagemagick.org/api/magick-image.php#MagickAutoThresholdImage for more information.
Sourcepub fn transform_image_colorspace(
&self,
colorspace: ColorspaceType,
) -> Result<(), MagickError>
pub fn transform_image_colorspace( &self, colorspace: ColorspaceType, ) -> Result<(), MagickError>
Set the image colorspace, transforming (unlike set_image_colorspace
) image data in
the process.
Sourcepub fn quantize_image(
&self,
number_of_colors: usize,
colorspace: ColorspaceType,
tree_depth: usize,
dither_method: DitherMethod,
measure_error: bool,
) -> Result<(), MagickError>
pub fn quantize_image( &self, number_of_colors: usize, colorspace: ColorspaceType, tree_depth: usize, dither_method: DitherMethod, measure_error: bool, ) -> Result<(), MagickError>
Reduce the number of colors in the image.
Sourcepub fn quantize_images(
&self,
number_of_colors: usize,
colorspace: ColorspaceType,
tree_depth: usize,
dither_method: DitherMethod,
measure_error: bool,
) -> Result<(), MagickError>
pub fn quantize_images( &self, number_of_colors: usize, colorspace: ColorspaceType, tree_depth: usize, dither_method: DitherMethod, measure_error: bool, ) -> Result<(), MagickError>
Reduce the number of colors in the images.
Sourcepub fn function_image(
&self,
function: MagickFunction,
args: &[f64],
) -> Result<(), MagickError>
pub fn function_image( &self, function: MagickFunction, args: &[f64], ) -> Result<(), MagickError>
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.
function
: the image function.args
: the function arguments.
§Example
This example show how you can apply smoothstep function (a polynomial -2x^3 + 3x^2
) to
every image pixel.
use magick_rust::{MagickWand, PixelWand, MagickFunction};
fn main() -> Result<(), magick_rust::MagickError> {
let mut wand1 = MagickWand::new();
wand1.new_image(4, 4, &PixelWand::new())?; // Replace with `read_image` to open your image file
// Apply smoothstep polynomial
wand1.function_image(MagickFunction::Polynomial, &[-2.0, 3.0, 0.0, 0.0])?;
Ok(())
}
Sourcepub fn polynomial_image(&self, terms: &[f64]) -> Result<(), MagickError>
pub fn polynomial_image(&self, terms: &[f64]) -> Result<(), MagickError>
Returns an image where each pixel is the sum of the pixels in the image sequence after applying its corresponding terms (coefficient and degree pairs).
terms
: the list of polynomial coefficients and degree pairs and a constant.
Sourcepub fn convolve_image(
&self,
kernel_info: &KernelInfo,
) -> Result<(), MagickError>
pub fn convolve_image( &self, kernel_info: &KernelInfo, ) -> Result<(), MagickError>
Applies a custom convolution kernel to the image.
kernel_info
: An array of doubles representing the convolution kernel.
Sourcepub fn morphology_image(
&self,
morphology_method: MorphologyMethod,
iterations: isize,
kernel_info: &KernelInfo,
) -> Result<(), MagickError>
pub fn morphology_image( &self, morphology_method: MorphologyMethod, iterations: isize, kernel_info: &KernelInfo, ) -> Result<(), MagickError>
Applies a user supplied kernel to the image according to the given morphology method.
morphology_method
: the morphology method to be applied.iterations
: apply the operation this many times (or no change). A value of -1 means loop until no change found. How this is applied may depend on the morphology method. Typically this is a value of 1.kernel_info
: An array of doubles representing the morphology kernel.
Sourcepub fn color_matrix_image(
&self,
color_matrix: &KernelInfo,
) -> Result<(), MagickError>
pub fn color_matrix_image( &self, color_matrix: &KernelInfo, ) -> Result<(), MagickError>
Apply color transformation to an image. The method permits saturation changes, hue rotation, luminance to alpha, and various other effects. Although variable-sized transformation matrices can be used, typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA (or RGBA with offsets). The matrix is similar to those used by Adobe Flash except offsets are in column 6 rather than 5 (in support of CMYKA images) and offsets are normalized (divide Flash offset by 255).
color_matrix
: the color matrix.
Sourcepub fn channel_fx_image(
&self,
expression: &str,
) -> Result<MagickWand, MagickError>
pub fn channel_fx_image( &self, expression: &str, ) -> Result<MagickWand, MagickError>
Applies a channel expression to the specified image. The expression consists of one or more channels, either mnemonic or numeric (e.g. red, 1), separated by actions as follows:
<=> exchange two channels (e.g. red<=>blue) => transfer a channel to another (e.g. red=>green) , separate channel operations (e.g. red, green) | read channels from next input image (e.g. red | green) ; write channels to next output image (e.g. red; green; blue) A channel without a operation symbol implies extract. For example, to create 3 grayscale images from the red, green, and blue channels of an image, use:
expression
: the expression.
Sourcepub fn combine_images(
&self,
colorspace: ColorspaceType,
) -> Result<MagickWand, MagickError>
pub fn combine_images( &self, colorspace: ColorspaceType, ) -> Result<MagickWand, MagickError>
Combines one or more images into a single image. The grayscale value of the pixels of each image in the sequence is assigned in order to the specified channels of the combined image. The typical ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.
colorspace
: the colorspace.
Sourcepub fn get_image(&self) -> Result<Image<'_>, MagickError>
pub fn get_image(&self) -> Result<Image<'_>, MagickError>
Returns the current image from the magick wand.
Sourcepub fn contrast_stretch_image(
&self,
black_point: f64,
white_point: f64,
) -> Result<(), MagickError>
pub fn contrast_stretch_image( &self, black_point: f64, white_point: f64, ) -> Result<(), MagickError>
Enhances contrast of an image by stretching the range of intensity values.
Sourcepub fn set_image_alpha(&self, alpha: f64) -> Result<(), MagickError>
pub fn set_image_alpha(&self, alpha: f64) -> Result<(), MagickError>
Sets the image to the specified alpha level.
Sourcepub fn modulate_image(
&self,
brightness: f64,
saturation: f64,
hue: f64,
) -> Result<(), MagickError>
pub fn modulate_image( &self, brightness: f64, saturation: f64, hue: f64, ) -> Result<(), MagickError>
Control the brightness, saturation, and hue of an image
Sourcepub fn brightness_contrast_image(
&self,
brightness: f64,
contrast: f64,
) -> Result<(), MagickError>
pub fn brightness_contrast_image( &self, brightness: f64, contrast: f64, ) -> Result<(), MagickError>
Control the brightness and contrast
Sourcepub fn set_image_alpha_channel(
&self,
alpha_channel: AlphaChannelOption,
) -> Result<(), MagickError>
pub fn set_image_alpha_channel( &self, alpha_channel: AlphaChannelOption, ) -> Result<(), MagickError>
Set the image alpha channel mode.
Sourcepub fn unique_image_colors(&self) -> Result<(), MagickError>
pub fn unique_image_colors(&self) -> Result<(), MagickError>
Discard all but one of any pixel color.
Sourcepub fn kmeans(
&self,
number_colors: usize,
max_iterations: usize,
tolerance: f64,
) -> Result<(), MagickError>
pub fn kmeans( &self, number_colors: usize, max_iterations: usize, tolerance: f64, ) -> Result<(), MagickError>
Applies k-means color reduction to the image.
Sourcepub fn auto_gamma(&self) -> Result<(), MagickError>
pub fn auto_gamma(&self) -> Result<(), MagickError>
Extracts the ‘mean’ from the image and adjust the image to try make set its gamma appropriately.
Sourcepub fn auto_level(&self) -> Result<(), MagickError>
pub fn auto_level(&self) -> Result<(), MagickError>
Adjusts the levels of a particular image channel by scaling the minimum and maximum values to the full quantum range.