Skip to content

Commit 415a693

Browse files
afcapeljeremy
authored andcommitted
Fix RAW images file type detection
For Sony and Canon Raw file formats. They are based on the tiff format and have the same magic number data so they are incorrectly classified as tiff images. Defining them as subtypes of tiff solves this issue: ```ruby Marcel::MimeType.for Pathname.new("/Users/afcapel/Downloads/RAW_SONY_ILCE-7M2.ARW"), name: "/Users/afcapel/Downloads/RAW_SONY_ILCE-7M2.ARW" => "image/x-raw-sony" ```
1 parent ccd4be5 commit 415a693

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

lib/marcel/mime_type/definitions.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
Marcel::MimeType.extend "image/heif", magic: [[4, "ftypmif1"]], extensions: %w( heif )
4444
Marcel::MimeType.extend "image/heic", magic: [[4, "ftypheic"]], extensions: %w( heic )
4545

46+
Marcel::MimeType.extend "image/x-raw-sony", extensions: %w( arw ), parents: "image/tiff"
47+
Marcel::MimeType.extend "image/x-raw-canon", extensions: %w( cr2 crw ), parents: "image/tiff"
48+
4649
Marcel::MimeType.extend "video/mp4", magic: [[4, "ftypisom"], [4, "ftypM4V "]], extensions: %w( mp4 m4v )
4750

4851
Marcel::MimeType.extend "audio/flac", magic: [[0, 'fLaC']], extensions: %w( flac ), parents: "audio/x-flac"
108 Bytes
Binary file not shown.
108 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)