Skip to main content

image_collage/
utils.rs

1use std::path::Path;
2
3/// Determines if a path points to a supported image file based on its extension.
4/// 
5/// # Supported formats
6/// 
7/// * JPEG (.jpg, .jpeg)
8/// * PNG (.png)
9/// * GIF (.gif)
10/// * BMP (.bmp)
11/// * WebP (.webp)
12/// * TIFF (.tiff, .tif)
13/// 
14/// # Arguments
15/// 
16/// * `path` - The file path to check
17/// 
18/// # Returns
19/// 
20/// `true` if the file extension indicates an image file, `false` otherwise
21pub fn is_image_file(path: &Path) -> bool {
22    if let Some(ext) = path.extension() {
23        let ext = ext.to_string_lossy().to_lowercase();
24        matches!(ext.as_str(), "jpg" | "jpeg" | "png" | "gif" | "bmp" | "webp" | "tiff" | "tif")
25    } else {
26        false
27    }
28}