Skip to content

Commit 80a41b2

Browse files
authored
Merge pull request #2559 from image-rs/recognize-pnm
recognize .pnm extension for PNM format
2 parents 3144ae6 + 7d8956f commit 80a41b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/io/format.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl ImageFormat {
7979
// thin wrapper function to strip generics
8080
fn inner(ext: &OsStr) -> Option<ImageFormat> {
8181
let ext = ext.to_str()?.to_ascii_lowercase();
82-
82+
// NOTE: when updating this, also update extensions_str()
8383
Some(match ext.as_str() {
8484
"avif" => ImageFormat::Avif,
8585
"jpg" | "jpeg" | "jfif" => ImageFormat::Jpeg,
@@ -93,7 +93,7 @@ impl ImageFormat {
9393
"ico" => ImageFormat::Ico,
9494
"hdr" => ImageFormat::Hdr,
9595
"exr" => ImageFormat::OpenExr,
96-
"pbm" | "pam" | "ppm" | "pgm" => ImageFormat::Pnm,
96+
"pbm" | "pam" | "ppm" | "pgm" | "pnm" => ImageFormat::Pnm,
9797
"ff" => ImageFormat::Farbfeld,
9898
"qoi" => ImageFormat::Qoi,
9999
_ => return None,
@@ -286,12 +286,13 @@ impl ImageFormat {
286286
/// that yields a slice of `OsStr` which is blocked by several features of const evaluation.
287287
#[must_use]
288288
pub fn extensions_str(self) -> &'static [&'static str] {
289+
// NOTE: when updating this, also update from_extension()
289290
match self {
290291
ImageFormat::Png => &["png"],
291292
ImageFormat::Jpeg => &["jpg", "jpeg"],
292293
ImageFormat::Gif => &["gif"],
293294
ImageFormat::WebP => &["webp"],
294-
ImageFormat::Pnm => &["pbm", "pam", "ppm", "pgm"],
295+
ImageFormat::Pnm => &["pbm", "pam", "ppm", "pgm", "pnm"],
295296
ImageFormat::Tiff => &["tiff", "tif"],
296297
ImageFormat::Tga => &["tga"],
297298
ImageFormat::Dds => &["dds"],

0 commit comments

Comments
 (0)