Search code examples
javascripthtmlimageinputphoto

NEF file format is not recognize in the image/* accept file


I am dealing with exotic imagery file format (RAW of various kind).

so, i have my

<input type="file" accept="image/*">

which work for mostly all format, but for some reason, NEF is not "accepted".

so I have to manually add it after image/*, which looks wrong.

<input ... accept="image/*, .nef"/>

this is not supported on firefox-linux , nor on opera or chrome-MAC. so i expect it's neither browser or OS dependant

I have read various documentation on the subject, i am not photographer myself, but considering it work with others format.

do you know why the nef format is not supported ?
more important : do you know if others format than NEF is not supported ?


Solution

  • The input element considers the image/* to handle image types. Webkit delegates the filter to the OS. For iOS, for instance, image/* instructs the dialog to select files belonging to the UTTypeImage type.

            if ([mimeType caseInsensitiveCompare:@"image/*"] == NSOrderedSame)
                [mediaTypes addObject:UTTypeImage.identifier];
    

    This type is equivalent to the public.image identifier you can see on System-Declared Uniform Type Identifiers.

    NEF files belong to the UTI com.nikon.raw-image which belongs to public.camera-raw-image which belongs to public.image.

    The problem seems to come from the fact that this is transmitted to UIDocumentPickerViewController@initWithDocumentTypes() which only takes considers UTI declared with UTExportedTypeDeclarations.

    You can view which type are Imported or Exported using the command

    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump
    

    Here's the result for NEF

            uti:           com.nikon.raw-image
            description:   Nikon raw image
            flags:         imported  active  core  apple-internal  
            icon:          
            conforms to:   public.camera-raw-image
            tags:          .nef
    

    This leaves us with the following list of images accepted by default when using image/* :

    • public.radiance : .pic, .hdr
    • public.jpeg : .jpeg, .jpg, .jpe, 'JPEG', image/jpeg
    • public.jpeg-2000 : .jp2, .jpf, .jpx, .j2k, 'jp2 ', image/jp2
    • com.apple.pict: .pict, .pct, .pic, 'PICT', image/pict, image/x-pict, image/x-macpict, "Apple PICT pasteboard type", "NSPICTPboardType"
    • com.apple.macpaint-image: .pntg, 'PNTG'
    • public.png: .png, 'PNGf', image/png, "Apple PNG pasteboard type"
    • public.svg-image: .svg, .svgz, 'svg ', 'svgz', image/svg+xml
    • com.apple.quicktime-image: .qtif, .qif, .qti, 'qtif', image/x-quicktime
    • com.apple.icns: .icns, 'icns'
    • public.xbitmap-image: .xbm, image/x-xbitmap