Function photon_rs::transform::crop

source ·
pub fn crop(
    photon_image: &mut PhotonImage,
    x1: u32,
    y1: u32,
    x2: u32,
    y2: u32
) -> PhotonImage
Expand description

Crop an image.

Arguments

  • img - A PhotonImage.

Example

// For example, to crop an image at (0, 0) to (500, 800)
use photon_rs::native::{open_image};
use photon_rs::transform::crop;
use photon_rs::PhotonImage;

let mut img = open_image("img.jpg").expect("File should open");
let cropped_img: PhotonImage = crop(&mut img, 0_u32, 0_u32, 500_u32, 800_u32);
// Write the contents of this image in JPG format.