Struct magick_rust::MagickWand
source · pub struct MagickWand {
pub wand: *mut MagickWand,
}
Fields§
§wand: *mut MagickWand
Implementations§
source§impl MagickWand
impl MagickWand
pub fn new() -> Self
pub fn new_from_wand(wand: *mut MagickWand) -> 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
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>
pub fn set_resource_limit( resource: ResourceType, limit: u64, ) -> Result<(), MagickError>
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.
pub fn clut_image( &self, clut_wand: &MagickWand, method: PixelInterpolateMethod, ) -> Result<(), MagickError>
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>
pub fn level_image( &self, black_point: f64, gamma: f64, white_point: f64, ) -> Result<(), MagickError>
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.
pub fn normalize_image(&self) -> Result<(), MagickError>
pub fn ordered_dither_image( &self, threshold_map: &str, ) -> Result<(), MagickError>
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<'wand>(&'wand self) -> Result<Image<'wand>, MagickError>
pub fn get_image<'wand>(&'wand self) -> Result<Image<'wand>, MagickError>
Returns the current image from the magick wand.
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.
pub fn get_image_colors(&self) -> usize
pub fn get_filename(&self) -> Result<String, MagickError>
pub fn set_filename(&mut self, s: &str) -> Result<(), MagickError>
pub fn get_font(&self) -> Result<String, MagickError>
pub fn set_font(&mut self, s: &str) -> Result<(), MagickError>
pub fn get_format(&self) -> Result<String, MagickError>
pub fn set_format(&mut self, s: &str) -> Result<(), MagickError>
pub fn get_image_filename(&self) -> Result<String, MagickError>
pub fn set_image_filename(&mut self, s: &str) -> Result<(), MagickError>
pub fn get_image_format(&self) -> Result<String, MagickError>
pub fn set_image_format(&mut self, s: &str) -> Result<(), MagickError>
pub fn fmt_string_settings(&self, f: &mut Formatter<'_>, prefix: &str) -> Result
pub fn get_colorspace(&self) -> ColorspaceType
pub fn set_colorspace(&mut self, v: ColorspaceType) -> Result<(), MagickError>
pub fn get_image_compose(&self) -> CompositeOperator
pub fn set_image_compose( &mut self, v: CompositeOperator, ) -> Result<(), MagickError>
pub fn get_compression(&self) -> CompressionType
pub fn set_compression(&mut self, v: CompressionType) -> Result<(), MagickError>
pub fn get_compression_quality(&self) -> usize
pub fn set_compression_quality(&mut self, v: usize) -> Result<(), MagickError>
pub fn get_gravity(&self) -> GravityType
pub fn set_gravity(&mut self, v: GravityType) -> Result<(), MagickError>
pub fn get_image_colorspace(&self) -> ColorspaceType
pub fn set_image_colorspace( &mut self, v: ColorspaceType, ) -> Result<(), MagickError>
pub fn get_image_compression(&self) -> CompressionType
pub fn set_image_compression( &mut self, v: CompressionType, ) -> Result<(), MagickError>
pub fn get_image_compression_quality(&self) -> usize
pub fn set_image_compression_quality( &mut self, v: usize, ) -> Result<(), MagickError>
pub fn get_image_delay(&self) -> usize
pub fn set_image_delay(&mut self, v: usize) -> Result<(), MagickError>
pub fn get_image_depth(&self) -> usize
pub fn set_image_depth(&mut self, v: usize) -> Result<(), MagickError>
pub fn get_image_dispose(&self) -> DisposeType
pub fn set_image_dispose(&mut self, v: DisposeType) -> Result<(), MagickError>
pub fn get_image_endian(&self) -> EndianType
pub fn set_image_endian(&mut self, v: EndianType) -> Result<(), MagickError>
pub fn get_image_fuzz(&self) -> f64
pub fn set_image_fuzz(&mut self, v: f64) -> Result<(), MagickError>
pub fn get_image_gamma(&self) -> f64
pub fn set_image_gamma(&mut self, v: f64) -> Result<(), MagickError>
pub fn get_image_gravity(&self) -> GravityType
pub fn set_image_gravity(&mut self, v: GravityType) -> Result<(), MagickError>
pub fn get_image_interlace_scheme(&self) -> InterlaceType
pub fn set_image_interlace_scheme( &mut self, v: InterlaceType, ) -> Result<(), MagickError>
pub fn get_image_interpolate_method(&self) -> PixelInterpolateMethod
pub fn set_image_interpolate_method( &mut self, v: PixelInterpolateMethod, ) -> Result<(), MagickError>
pub fn get_image_iterations(&self) -> usize
pub fn set_image_iterations(&mut self, v: usize) -> Result<(), MagickError>
pub fn get_image_orientation(&self) -> OrientationType
pub fn set_image_orientation( &mut self, v: OrientationType, ) -> Result<(), MagickError>
pub fn get_image_rendering_intent(&self) -> RenderingIntent
pub fn set_image_rendering_intent( &mut self, v: RenderingIntent, ) -> Result<(), MagickError>
pub fn get_image_scene(&self) -> usize
pub fn set_image_scene(&mut self, v: usize) -> Result<(), MagickError>
pub fn get_image_type(&self) -> ImageType
pub fn set_image_type(&mut self, v: ImageType) -> Result<(), MagickError>
pub fn get_image_units(&self) -> ResolutionType
pub fn set_image_units(&mut self, v: ResolutionType) -> Result<(), MagickError>
pub fn get_interlace_scheme(&self) -> InterlaceType
pub fn set_interlace_scheme( &mut self, v: InterlaceType, ) -> Result<(), MagickError>
pub fn get_interpolate_method(&self) -> PixelInterpolateMethod
pub fn set_interpolate_method( &mut self, v: PixelInterpolateMethod, ) -> Result<(), MagickError>
pub fn get_iterator_index(&self) -> isize
pub fn set_iterator_index(&mut self, v: isize) -> Result<(), MagickError>
pub fn get_orientation(&self) -> OrientationType
pub fn set_orientation(&mut self, v: OrientationType) -> Result<(), MagickError>
pub fn get_pointsize(&self) -> f64
pub fn set_pointsize(&mut self, v: f64) -> Result<(), MagickError>
pub fn get_type(&self) -> ImageType
pub fn set_type(&mut self, v: ImageType) -> Result<(), MagickError>
pub fn fmt_checked_settings( &self, f: &mut Formatter<'_>, prefix: &str, ) -> Result
Trait Implementations§
source§impl Clone for MagickWand
impl Clone for MagickWand
source§impl Debug for MagickWand
impl Debug for MagickWand
source§impl Drop for MagickWand
impl Drop for MagickWand
impl Send for MagickWand
Auto Trait Implementations§
impl Freeze for MagickWand
impl RefUnwindSafe for MagickWand
impl !Sync for MagickWand
impl Unpin for MagickWand
impl UnwindSafe for MagickWand
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)