pub struct Picture { /* private fields */ }
Expand description
External images.
The Picture structure is responsible for defining and adjusting external images that will be included in the image being built. It allows for cropping, resizing, and positioning to compose the final image.
⚠️ It’s important to note that if there is both cropping and resizing on the same image, the library will always perform cropping first, and then resizing. ⚠️
§Example
use image_builder::Picture;
use image::DynamicImage;
Picture::new(file_bytes)
.resize(100, 100, FilterType::Triangle) // Resizing is specified here, but the library will first perform the cropping below, and then this resizing.
.crop(50, 50, 200, 200);
In the example above, an image of 300x300 pixels was imported, a square of 200x200 pixels was cropped, and then this cropped portion was resized by half, resulting in an image of 100x100 pixels.
Implementations§
Source§impl Picture
impl Picture
Sourcepub fn new(img: DynamicImage) -> Picture
pub fn new(img: DynamicImage) -> Picture
This method instantiates an external image using the file path of the image and positions it at the point (0,0) of the image being built.
§Example
use image::DynamicImage;
use image_builder::Picture;
Picture::new(image);
Sourcepub fn resize(&mut self, width: u32, height: u32, filter: FilterType) -> Self
pub fn resize(&mut self, width: u32, height: u32, filter: FilterType) -> Self
This method allows resizing an image by specifying the desired new height, width and FilterType
.
§Example
use image_builder::Picture;
Picture::new("/home/user/logo.png")
.resize(200, 100, FilterType::Triangle);
Sourcepub fn crop(&mut self, x: u32, y: u32, width: u32, height: u32) -> Self
pub fn crop(&mut self, x: u32, y: u32, width: u32, height: u32) -> Self
Use this method to crop an imported image by providing the starting point of the crop (x, y), as well as the desired height and width to be cropped.
§Example
use image_builder::Picture;
Picture::new("/home/user/logo.png")
.crop(50, 50, 200, 200);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Picture
impl RefUnwindSafe for Picture
impl Send for Picture
impl Sync for Picture
impl Unpin for Picture
impl UnwindSafe for Picture
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.