v1.3.0-rc30 - BREAKING changes to JSON API
Pre-release
Pre-release
- Add
mode=aspectcrop
to ImageResizer commands andConstrainMode::AspectCrop
to JSON API for minimally cropping to the aspect ratio described byw
andh
- Fix ABI tests and improve function name reporting in said error messages
- JSON BREAKING:
copy_rect_to_canvas
node: .width and .height are now .w and .h - JSON BREAKING:
resample_2d
node: .down_filter, up_filter, scaling_colorspace duplicate fields have been removed (they are now in .hints) - JSON BREAKING:
constrain
has been refactored
New Constrain JSON
"constrain" = {
"mode"= [constraint mode]
"w" = unsigned integer
"h" = unsigned integer
"gravity" = { "percentage" = {x: float, y: float }},
"canvas_color" = (color value)
"hints" = {
resample_hints
}
// Where [constraint mode] is one of these. Use the value in serde(rename) for JSON.
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum ConstraintMode {
/// Distort the image to exactly the given dimensions.
/// If only one dimension is specified, behaves like `fit`.
#[serde(rename = "distort")]
Distort,
/// Ensure the result fits within the provided dimensions. No upscaling.
#[serde(rename = "within")]
Within,
/// Fit the image within the dimensions, upscaling if needed
#[serde(rename = "fit")]
Fit,
/// Ensure the image is larger than the given dimensions
#[serde(rename = "larger_than")]
LargerThan,
/// Crop to desired aspect ratio if image is larger than requested, then downscale. Ignores smaller images.
/// If only one dimension is specified, behaves like `within`.
#[serde(rename = "within_crop")]
WithinCrop,
/// Crop to desired aspect ratio, then downscale or upscale to fit.
/// If only one dimension is specified, behaves like `fit`.
#[serde(rename = "fit_crop")]
FitCrop,
/// Crop to desired aspect ratio, no upscaling or downscaling. If only one dimension is specified, behaves like Fit.
#[serde(rename = "aspect_crop")]
AspectCrop,
/// Pad to desired aspect ratio if image is larger than requested, then downscale. Ignores smaller images.
/// If only one dimension is specified, behaves like `within`
#[serde(rename = "within_pad")]
WithinPad,
/// Pad to desired aspect ratio, then downscale or upscale to fit
/// If only one dimension is specified, behaves like `fit`.
#[serde(rename = "fit_pad")]
FitPad,
}
Where [resample hints] includes
pub sharpen_percent: Option<f32>,
pub down_filter: Option<Filter>,
pub up_filter: Option<Filter>,
pub scaling_colorspace: Option<ScalingFloatspace>,
pub background_color: Option<Color>,
pub resample_when: Option<ResampleWhen>,
pub sharpen_when: Option<SharpenWhen>