pub struct ImageInstance { /* private fields */ }Expand description
An immutable image with a queue of pending transformations.
Mirrors Illuminate\Image\Image: transformations are chained fluently,
processed in order, and the image is only encoded once at the end.
Implementations§
Source§impl ImageInstance
impl ImageInstance
Sourcepub fn resize(&self, width: Option<u32>, height: Option<u32>) -> Result<Self>
pub fn resize(&self, width: Option<u32>, height: Option<u32>) -> Result<Self>
Resize the image to the given dimensions. Either width or height may be omitted to preserve the aspect ratio.
Sourcepub fn scale(&self, width: Option<u32>, height: Option<u32>) -> Result<Self>
pub fn scale(&self, width: Option<u32>, height: Option<u32>) -> Result<Self>
Proportionally scale the image down so it fits within the given dimensions. Never increases the image size.
Sourcepub fn cover(&self, width: u32, height: u32) -> Self
pub fn cover(&self, width: u32, height: u32) -> Self
Resize and crop the image to completely cover the given dimensions.
Sourcepub fn contain(&self, width: u32, height: u32, background: Option<&str>) -> Self
pub fn contain(&self, width: u32, height: u32, background: Option<&str>) -> Self
Resize the image to fit within the given dimensions while preserving
the entire image. Empty space is filled with the optional background
color ("#ffffff", "dominant", or None for transparent).
Sourcepub fn crop(&self, width: u32, height: u32, x: u32, y: u32) -> Self
pub fn crop(&self, width: u32, height: u32, x: u32, y: u32) -> Self
Crop the image to the given dimensions and position.
Sourcepub fn rotate(&self, angle: f32, background: Option<&str>) -> Self
pub fn rotate(&self, angle: f32, background: Option<&str>) -> Self
Rotate the image clockwise by the given angle (degrees), filling the
background with the optional color ("#ffffff" / "dominant").
Sourcepub fn blur(&self, amount: u8) -> Self
pub fn blur(&self, amount: u8) -> Self
Apply a gaussian blur. amount is clamped between 0 and 100.
Sourcepub fn sharpen(&self, amount: u8) -> Self
pub fn sharpen(&self, amount: u8) -> Self
Sharpen the image (unsharp mask). amount is clamped between 0 and 100.
Sourcepub fn flip_vertically(&self) -> Self
pub fn flip_vertically(&self) -> Self
Flip the image vertically.
Sourcepub fn flip_horizontally(&self) -> Self
pub fn flip_horizontally(&self) -> Self
Flip the image horizontally.
Sourcepub fn quality(&self, quality: u8) -> Self
pub fn quality(&self, quality: u8) -> Self
Set the output quality, clamped between 1 and 100. Applies to lossy encoders (JPEG); other encoders use their default settings.
Sourcepub fn to_format(&self, format: OutputFormat) -> Self
pub fn to_format(&self, format: OutputFormat) -> Self
Convert the image to the given format.
Sourcepub fn optimize(&self, format: OutputFormat, quality: u8) -> Self
pub fn optimize(&self, format: OutputFormat, quality: u8) -> Self
Convenience for converting to a format and setting quality.
Sourcepub fn to_base64(&self) -> Result<String>
pub fn to_base64(&self) -> Result<String>
Process the image and return it as a base64 encoded string.
Sourcepub fn to_data_uri(&self) -> Result<String>
pub fn to_data_uri(&self) -> Result<String>
Process the image and return it as a data URI.
Sourcepub fn dimensions(&self) -> Result<(u32, u32)>
pub fn dimensions(&self) -> Result<(u32, u32)>
The dimensions of the processed image as (width, height).
Sourcepub fn dominant_color(&self) -> Result<String>
pub fn dominant_color(&self) -> Result<String>
The dominant (average) color of the processed image as a hex string.
Sourcepub fn save(&self, path: &Path) -> Result<String>
pub fn save(&self, path: &Path) -> Result<String>
Write the processed image to path, creating parent directories.
Returns the path on success.
Sourcepub fn store(&self, path: &str) -> Result<String>
pub fn store(&self, path: &str) -> Result<String>
Store the processed image on the local disk under storage/app.
Returns the relative stored path.
Sourcepub fn store_as(&self, path: &str, name: &str) -> Result<String>
pub fn store_as(&self, path: &str, name: &str) -> Result<String>
Store the processed image on the local disk under storage/app
with the given name. Returns the relative stored path.
Sourcepub fn store_publicly(&self, path: &str) -> Result<String>
pub fn store_publicly(&self, path: &str) -> Result<String>
Store the processed image with public visibility. The local disk does
not model visibility, so this is equivalent to store.
Trait Implementations§
Source§impl Clone for ImageInstance
impl Clone for ImageInstance
Auto Trait Implementations§
impl Freeze for ImageInstance
impl RefUnwindSafe for ImageInstance
impl Send for ImageInstance
impl Sync for ImageInstance
impl Unpin for ImageInstance
impl UnsafeUnpin for ImageInstance
impl UnwindSafe for ImageInstance
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Event for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more