Skip to main content

Crate use_media

Crate use_media 

Source
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§

attribute
color
document
element
image_aspect_ratio
normalize
orientation
path
size
transform
view_box

Structs§

AspectRatio
Bitrate
Dimensions
FrameRate
ImageAspectRatio
Integer image aspect ratio.
ImageMetadata
Small image metadata bundle for callers that already know or discovered a format.
ImageSize
Basic image dimensions.
MediaDuration
MediaTimestamp
MediaType
SvgAttribute
SvgDocument
SvgElement
SvgMetadata
SvgPath
SvgSize
SvgTransform
SvgViewBox

Enums§

AspectRatioError
BitrateError
DimensionsError
FrameRateError
ImageFormat
Common image formats handled by this crate.
ImageKind
Broad classification for image container types.
ImageOrientation
Common image orientation buckets.
MediaDurationError
MediaKind
MediaTimestampError
MediaTypeError
ResolutionClass
ResolutionError

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