marcel icon indicating copy to clipboard operation
marcel copied to clipboard

[Bug] Cannon .CR2 file is not properly detected

Open bogdan opened this issue 2 months ago • 0 comments

The following file is not properly detected as image/x-canon-cr2:

https://realphotos.mypinata.cloud/ipfs/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq

Reference shell:

URL="http://silver-naval-alligator-759.mypinata.cloud/files/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq"; mime_head=$(curl -sI "$URL" | grep -i "^content-type:" | awk '{print $2}' | tr -d '\r'); [ -n "$mime_head" ] && echo "$mime_head" || { tmp=$(mktemp); curl -s --range 0-4095 "$URL" -o "$tmp"; file --mime-type -b "$tmp"; rm -f "$tmp"; }
# => image/x-canon-cr2

Reproduce script:

#!/usr/bin/env ruby

require 'open-uri'
require 'marcel'

url = "http://silver-naval-alligator-759.mypinata.cloud/files/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq"

io = URI.open(url, "rb", content_length_proc: ->(len) { puts "Fetching #{len} bytes..." if len })
head = io.read(4096)
io.rewind

mime_type = Marcel::MimeType.for(StringIO.new(head), name: File.basename(url))
puts "Detected MIME type: #{mime_type}"

Output:

Detected MIME type: image/tiff

bogdan avatar Nov 07 '25 13:11 bogdan