Expand description
Thin facade for the use-media workspace.
The crate reexports the focused media crates directly so consumers can opt into one dependency while still using the smaller APIs.
§Examples
use use_media::*;
let dimensions = Dimensions::new(1920, 1080).unwrap();
let aspect = AspectRatio::new(1920, 1080).unwrap();
let mime = parse_media_type("video/mp4").unwrap();
assert_eq!(classify_resolution(1920, 1080).unwrap(), ResolutionClass::FullHd);
assert_eq!(aspect.label(), "16:9");
assert_eq!(mime.kind(), MediaKind::Video);
assert_eq!(dimensions.area(), 2_073_600);Re-exports§
pub use use_aspect_ratio;pub use use_bitrate;pub use use_dimensions;pub use use_frame_rate;pub use use_image;pub use use_media_duration;pub use use_media_timestamp;pub use use_media_type;pub use use_resolution;pub use use_svg;
Modules§
Structs§
- Aspect
Ratio - Bitrate
- Dimensions
- Frame
Rate - Image
Aspect Ratio - Integer image aspect ratio.
- Image
Metadata - Small image metadata bundle for callers that already know or discovered a format.
- Image
Size - Basic image dimensions.
- Media
Duration - Media
Timestamp - Media
Type - SvgAttribute
- SvgDocument
- SvgElement
- SvgMetadata
- SvgPath
- SvgSize
- SvgTransform
- SvgView
Box
Enums§
- Aspect
Ratio Error - Bitrate
Error - Dimensions
Error - Frame
Rate Error - Image
Format - Common image formats handled by this crate.
- Image
Kind - Broad classification for image container types.
- Image
Orientation - Common image orientation buckets.
- Media
Duration Error - Media
Kind - Media
Timestamp Error - Media
Type Error - Resolution
Class - Resolution
Error
Functions§
- aspect_
label - aspect_
ratio - aspect_
ratio_ f64 - Returns the floating-point aspect ratio when the height is non-zero.
- bitrate_
from_ size - bits_
for_ duration - build_
svg_ document - build_
svg_ icon - bytes_
for_ duration - clamp_
timestamp - classify_
resolution - cover_
size - Scales a size so it fully covers bounds, preserving aspect ratio.
- detect_
image_ format_ from_ bytes - Detects an image format from common magic bytes without fully parsing the file.
- detect_
image_ format_ from_ extension - Detects an image format from a file extension.
- detect_
image_ format_ from_ mime - Detects an image format from a MIME type string.
- duration_
from_ frames - duration_
from_ samples - extension_
from_ filename - Extracts a filename extension without changing its original case.
- extract_
attributes - extract_
description - extract_
fill_ values - extract_
height - extract_
metadata - extract_
path_ data - extract_
paths - extract_
size - extract_
stroke_ values - extract_
svg_ root - extract_
title - extract_
transform_ values - extract_
view_ box - extract_
width - fit_
image_ within - Scales a size to fit completely within bounds, preserving aspect ratio.
- fit_
within - fits_
aspect_ ratio - format_
duration_ hms - format_
timestamp - format_
view_ box - frame_
count - frame_
duration_ seconds - frame_
index_ at_ time - get_
attribute - has_
attribute - has_
svg_ root - image_
aspect_ ratio - Simplifies a size into its smallest whole-number aspect ratio.
- image_
extension - Returns the canonical extension without a leading dot.
- image_
kind - Returns the broad image kind for a format.
- image_
mime_ type - Returns the canonical MIME type for a format.
- is_
audio_ mime - is_
image_ extension - Returns true when the input is a known image extension.
- is_
image_ mime - is_
known_ image_ mime - Returns true when the input is a known image MIME type.
- is_
landscape - is_
portrait - is_
raster_ image - Returns true when the format is raster-based.
- is_
square - is_
standard_ frame_ rate - is_svg
- is_
vector_ image - Returns true when the format is vector-based.
- is_
video_ mime - is_
web_ image_ format - Returns true for formats commonly used in browsers and web asset pipelines.
- kilobits_
per_ second - media_
kind_ from_ mime - megabits_
per_ second - megapixels
- millis_
to_ seconds - minify_
svg_ basic - normalize_
extension - Normalizes an image extension to a canonical lowercase value without a dot.
- normalize_
svg - normalize_
transform - orientation
- Detects the orientation for a size.
- parse_
element - parse_
media_ type - parse_
view_ box - pixel_
area - pixels
- scale_
dimensions - scale_
to_ height - Scales a size to an exact height and rounded matching width.
- scale_
to_ width - Scales a size to an exact width and rounded matching height.
- seconds_
to_ millis - simplify_
ratio - strip_
comments - strip_
xml_ declaration - supports_
animation - Returns true when the format commonly supports animation.
- supports_
transparency - Returns true when the format can commonly carry transparency.
- timestamp_
from_ frame