pub struct Image {
pub filename: String,
pub width: u32,
pub height: u32,
pub x: u32,
pub y: u32,
pub format: String,
pub source: Option<ImageSource>,
pub crop: Option<Crop>,
pub effects: Vec<ImageEffect>,
pub alt_text: Option<String>,
}Expand description
Image metadata and properties
Fields§
§filename: String§width: u32§height: u32§x: u32§y: u32§format: String§source: Option<ImageSource>Image data source (file path, base64, or bytes)
crop: Option<Crop>Image cropping
effects: Vec<ImageEffect>Image effects
alt_text: Option<String>Accessibility alt text (description)
Implementations§
Source§impl Image
impl Image
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, String>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, String>
Create an image from a file path, automatically detecting dimensions
Sourcepub fn from_base64(data: &str, width: u32, height: u32, format: &str) -> Self
pub fn from_base64(data: &str, width: u32, height: u32, format: &str) -> Self
Create an image from base64 encoded data
§Example
use ppt_rs::generator::Image;
let base64_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
let img = Image::from_base64(base64_data, 100, 100, "PNG")
.position(1000000, 1000000);
assert_eq!(img.width, 100);
assert_eq!(img.height, 100);
assert_eq!(img.format, "PNG");Sourcepub fn from_bytes(data: Vec<u8>, width: u32, height: u32, format: &str) -> Self
pub fn from_bytes(data: Vec<u8>, width: u32, height: u32, format: &str) -> Self
Create an image from raw bytes
Sourcepub fn with_alt_text(self, alt: &str) -> Self
pub fn with_alt_text(self, alt: &str) -> Self
Set accessibility alt text for the image.
Sourcepub fn get_bytes(&self) -> Option<Vec<u8>>
pub fn get_bytes(&self) -> Option<Vec<u8>>
Get the image data as bytes (decodes base64 if needed)
Sourcepub fn with_crop(self, left: f64, top: f64, right: f64, bottom: f64) -> Self
pub fn with_crop(self, left: f64, top: f64, right: f64, bottom: f64) -> Self
Set image cropping
Sourcepub fn with_effect(self, effect: ImageEffect) -> Self
pub fn with_effect(self, effect: ImageEffect) -> Self
Add an image effect
Sourcepub fn aspect_ratio(&self) -> f64
pub fn aspect_ratio(&self) -> f64
Get aspect ratio
Sourcepub fn scale_to_width(self, width: u32) -> Self
pub fn scale_to_width(self, width: u32) -> Self
Scale image to width while maintaining aspect ratio
Sourcepub fn scale_to_height(self, height: u32) -> Self
pub fn scale_to_height(self, height: u32) -> Self
Scale image to height while maintaining aspect ratio
Sourcepub fn at(self, x: Dimension, y: Dimension) -> Self
pub fn at(self, x: Dimension, y: Dimension) -> Self
Set position using flexible Dimension units (fluent).
Sourcepub fn with_dimensions(self, width: Dimension, height: Dimension) -> Self
pub fn with_dimensions(self, width: Dimension, height: Dimension) -> Self
Set size using flexible Dimension units (fluent).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
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
Mutably borrows from an owned value. Read more