Skip to main content

Op

Enum Op 

Source
#[non_exhaustive]
pub enum Op {
Show 40 variants Resize { width: u32, height: u32, mode: ResizeMode, }, Thumbnail { width: u32, height: u32, mode: ResizeMode, }, Define { key: String, value: Option<String>, }, Blur { radius: u32, sigma: f32, }, Edge { radius: u32, }, Colors { count: u32, dither: Dither, }, Format(String), Quality(u32), Strip, Depth(u8), EncoderOpt { key: String, value: String, }, Threads(usize), Density(u32), Background([u8; 4]), Alpha(AlphaOp), Rotate { degrees: i32, }, Flip, Flop, Crop { x: u32, y: u32, w: u32, h: u32, }, Negate, Sharpen { radius: u32, sigma: f32, }, Unsharp { radius: u32, sigma: f32, amount: f32, threshold: u8, }, Gamma { value: f32, }, BrightnessContrast { brightness: f32, contrast: f32, }, Contrast { delta: i32, }, Sepia { threshold: f32, }, Modulate { brightness: f32, saturation: f32, hue: f32, }, Level { black: u8, gamma: f32, white: u8, }, Normalize, Threshold { value: u8, }, Posterize { levels: u32, }, Solarize { value: u8, }, Colorspace(String), Vignette { radius: f32, sigma: f32, x: f32, y: f32, }, Colorize { color: [u8; 4], amount: f32, }, Equalize, AutoGamma, Extent { width: u32, height: u32, x: i32, y: i32, bg: [u8; 4], }, Trim { fuzz: u8, }, Roll { dx: i32, dy: i32, },
}
Expand description

One convert operation.

Operations apply in source order — same as imagemagick convert, even though we don’t yet support IM’s stack-reset semantics.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Resize

-resize WxH[!^<>%@]. The trailing modifier selects the scaling policy via ResizeMode; absence of any modifier is ResizeMode::Default (aspect-preserving fit-inside).

Fields

§width: u32
§height: u32
§

Thumbnail

-thumbnail WxH[!^<>%@] — IM convenience flag. Same geometry grammar as -resize; the runner unrolls it into a Resize plus Strip pair (and, eventually, an auto-orient pass) so the downstream pipeline doesn’t need a dedicated thumbnail node.

Fields

§width: u32
§height: u32
§

Define

-define KEY[=VALUE] — opaque codec-specific tunable forwarded to the sink. Keys keep their literal form (e.g. jpeg:dct-method); the sink encoder picks up keys it recognises and silently ignores the rest, mirroring IM’s “tolerant of irrelevant options” posture. Bare -define KEY (no =VALUE) sets the key to JSON true.

Fields

§

Blur

-blur RxS. Sigma defaults to radius / 2.0 when the xS portion is omitted (matches IM’s convention).

Fields

§radius: u32
§sigma: f32
§

Edge

-edge R. Radius ignored by the current Sobel impl but parsed for forward-compatibility.

Fields

§radius: u32
§

Colors

-colors N paired with an optional -dither preceding it. When present, the output is paletted via oxideav_pixfmt before encoding.

Fields

§count: u32
§dither: Dither
§

Format(String)

-format FMT — override the container/codec decision otherwise derived from the output extension.

§

Quality(u32)

-quality N — forwarded to the sink codec (e.g. JPEG quality, WebP quality). Silently dropped by codecs that don’t honour it.

§

Strip

-strip — request that metadata (EXIF, XMP, ID3, etc.) be dropped on write.

§

Depth(u8)

-depth N — output bit depth per channel for still-image sinks (8 or 16). Caps the encoder input layout the planner picks (a 10-bit HEIC → -depth 8 → 8-bit PNG) or asks for the deeper layout (-depth 16). Without it the source’s own depth is kept when the encoder can carry it.

§

EncoderOpt

--opt KEY=VALUE — an encoder option for still-image sinks, validated against the target encoder’s declared options schema (the keys oxideav info <codec> lists) and handed to the encoder convert builds for the output. Repeatable; a later value for the same key wins.

Fields

§value: String
§

Threads(usize)

-threads N — thread budget for the pipeline route (the job’s threads key: codec-internal fan-out and the frame-tap encoder). 0 means auto (the host’s parallelism, the default).

§

Density(u32)

-density N — DPI for vector→raster conversion. PDF / SVG pages are measured in PostScript points (1/72 inch); a page at 300 DPI rasterises to points × (300 / 72) pixels per axis. Ignored on raster-only inputs.

§

Background([u8; 4])

-background COLOR — canvas fill colour used by the rasteriser and by -alpha remove. CSS L3 named colours and #hex 3/4/6/8 forms accepted (same parser as xc:).

§

Alpha(AlphaOp)

-alpha SUBCOMMAND — see AlphaOp.

§

Rotate

-rotate N — rotate by N degrees. Round-1 supports only multiples of 90 (90/180/270 and the negatives). Other angles are rejected by the args parser with a “only multiples of 90 supported” message.

Fields

§degrees: i32
§

Flip

-flip — vertical flip (reverse row order).

§

Flop

-flop — horizontal flip (reverse column order within each row).

§

Crop

-crop WxH+X+Y — extract a WxH bounding box at offset (X,Y). The args parser accepts the IM grammar; runtime checks that the bbox fits inside the input dimensions and errors cleanly when it doesn’t.

Fields

§

Negate

-negate — per-pixel out = 255 - in on the colour channels; alpha (when present) is unchanged.

§

Sharpen

-sharpen RxS — unsharp-mask sharpening with radius / sigma (amount defaults to 1.0 in the factory). Sigma defaults to radius / 2.0 when only R is given.

Fields

§radius: u32
§sigma: f32
§

Unsharp

-unsharp RxS+amount+threshold — full unsharp-mask grammar. Amount and threshold each default to a sensible value when omitted (amount = 1.0, threshold = 0).

Fields

§radius: u32
§sigma: f32
§amount: f32
§threshold: u8
§

Gamma

-gamma G — power-law gamma correction. G > 0.

Fields

§value: f32
§

BrightnessContrast

-brightness-contrast B[,C] — brightness in [-100..=100], contrast in [-100..=100] (both percent-of-range). Either argument may be omitted; the IM grammar tolerates B, Bx, BxC, B,C.

Fields

§brightness: f32
§contrast: f32
§

Contrast

-contrast (no value) — IM applies a tiny per-channel contrast step. Multiple -contrast flags accumulate; we collapse them into a single delta carried on the op (positive for -contrast, negative for +contrast, which IM uses for the inverse). The factory wires this to BrightnessContrast::new(0, 5*delta) — a 5-percent step matching IM’s “single contrast bump” feel.

Fields

§delta: i32
§

Sepia

-sepia THRESHOLD% — warm-tint mapping. threshold is a scalar in 0.0..=1.0 (IM expresses it as a percentage of the dynamic range; we accept either form on parse).

Fields

§threshold: f32
§

Modulate

-modulate B,S,H — IM’s HSL-style triplet. Each component is percent-of-base around 100 (so 100,100,0 is identity, 200 doubles, 0 zeros, etc.). The hue field is “hue offset percent” but image-filter takes degrees; we translate.

Fields

§brightness: f32
§saturation: f32
§hue: f32
§

Level

-level B/G/W — input black point, gamma, white point. Black and white are 0..=255; gamma must be > 0.

Fields

§black: u8
§gamma: f32
§white: u8
§

Normalize

-normalize — stretch the histogram to fill 0..=255.

§

Threshold

-threshold N% — binarise: pixels below value map to 0, pixels at or above map to 255.

Fields

§value: u8
§

Posterize

-posterize N — collapse to N levels per channel.

Fields

§levels: u32
§

Solarize

-solarize N% — invert pixels above the threshold.

Fields

§value: u8
§

Colorspace(String)

-colorspace gray|grey|rgb|srgb — round-1 covers only the grayscale conversion (everything else is treated as a pass-through, keeping the input colourspace).

§

Vignette

-vignette R+S+X+Y — Gaussian radial darkening centred at (x, y). radius/sigma are in pixels (sigma defaults to radius / 2.0 when omitted, matching IM); x/y are normalised image-relative offsets in [0.0, 1.0] (the image-filter factory takes them this way to stay resolution-independent), defaulting to 0.5 / 0.5 (image centre) when omitted.

Fields

§radius: f32
§sigma: f32
§

Colorize

-colorize C[xC[xC]]/A% — linear blend toward a target colour by amount. color is [R, G, B, A] (alpha defaults to 255); amount is a unit scalar in [0.0, 1.0] (IM expresses it as a percentage of the dynamic range).

Fields

§color: [u8; 4]
§amount: f32
§

Equalize

-equalize (no value) — per-channel histogram equalisation via CDF mapping.

§

AutoGamma

-auto-gamma (no value) — auto-gamma: pick a per-channel gamma so the geometric mean lands at 0.5.

§

Extent

-extent WxH[+X+Y] — re-window the input onto a fixed WxH canvas. The source is placed at signed offset (x, y) (default (0, 0), IM’s top-left convention); pixels outside the source rectangle are painted with bg (RGBA). Offsets may be negative (-extent 100x100-10-10) to translate the source toward the upper-left so its right / bottom edge can land inside the window. Unlike Crop (only shrinks) and Resize (only scales), Extent can both add canvas and discard content depending on the requested geometry.

bg is captured at args-parse time from the most recent -background op seen in source order (defaulting to IM’s opaque white [255, 255, 255, 255] when none was set). Pinning the colour onto the op preserves source-order semantics — a later -background does NOT retroactively repaint an earlier -extent’s padding.

Fields

§width: u32
§height: u32
§bg: [u8; 4]
§

Trim

-trim — auto-crop to the bounding box of pixels that differ from a reference background colour by more than fuzz per channel. The reference colour is the input’s (0, 0) pixel (matching IM’s behaviour when no -bordercolor/-background override is set). fuzz defaults to 0 (exact match); a preceding -fuzz N[%] flag updates the value carried on this op at args-parse time, so source order is preserved (-fuzz 10 -trim -fuzz 0 -trim lands as Trim { fuzz: 10 }, Trim { fuzz: 0 }).

Fields

§fuzz: u8
§

Roll

-roll ±X±Y — circular pixel shift. dx shifts columns to the right by dx pixels (negative = left); dy shifts rows down by dy pixels (negative = up). Pixels that fall off one edge wrap around to the opposite edge — width and height stay unchanged, and the total pixel count is preserved. The IM grammar requires both X and Y signed (-roll +5+10, -roll -3+2); a single offset (-roll +5) is rejected at parse time.

Fields

§dx: i32
§dy: i32

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Op

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Op

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V