kaitai-io / kaitai_struct_formats

Kaitai Struct: library of binary file formats (.ksy)
http://formats.kaitai.io
708 stars 204 forks source link

Add Apple ICNS #218

Open KOLANICH opened 5 years ago

KOLANICH commented 5 years ago
meta:
  id: apple_icns
  title: Apple Icon Image format
  application:
    - Apple MacOS
  file-extension: icns
  xref:
    justsolve: ICNS
    mime: image/icns
    uti: com.apple.icns
    wikidata: Q2858737

doc: |
  Icons file format used in Apple MacOS.

doc-ref:
  - https://en.wikipedia.org/wiki/Apple_Icon_Image_format
WiP:
  - 312
dgelessus commented 5 years ago

Regarding application: as far as I know, icns icons are only used on macOS. On other Apple systems (iOS, watchOS, tvOS), multi-resolution icons are stored as individual image files or in an asset catalog (a .car file). So I think it would make more sense to list only "Apple macOS" as the application and remove "Apple" from the list.

Also I see you've added a uti key under xref. Has this key been used elsewhere before and/or is it documented somewhere? I'm asking because I also thought about adding UTIs to Kaitai Struct specs, but I wasn't sure if they were notable/widespread enough (as far as I know, UTIs are only used on Apple systems).

dgelessus commented 5 years ago

I'm also wondering where the MIME type image/icns comes from. On my macOS 10.14 system, according to the CoreServices APIs, the UTI for ICNS files only has a file extension registered, but no MIME type:

import CoreServices
import Foundation

debugPrint(UTTypeCopyAllTagsWithClass(kUTTypeAppleICNS, kUTTagClassFilenameExtension)!.takeRetainedValue())
// <__NSSingleObjectArrayI 0x10010ede0>(
// icns
// )
debugPrint(UTTypeCopyAllTagsWithClass(kUTTypeAppleICNS, kUTTagClassMIMEType))
// nil

And according to file --mime-type, the MIME type is image/x-icns:

$ file --mime-type /Applications/TextEdit.app/Contents/Resources/Edit.icns
/Applications/TextEdit.app/Contents/Resources/Edit.icns: image/x-icns

ICNS was added to the file database in https://github.com/file/file/commit/a08d0291268365d50bea9a8a92f00a37b7c626b1, but I'm not sure where the information on the MIME type comes from.

KOLANICH commented 5 years ago

Also I see you've added a uti key under xref. Has this key been used elsewhere before and/or is it documented somewhere?

AFAIK, no.

I'm also wondering where the MIME type image/icns comes from.

Just googling. That mime type is not official and not widely adopeted. Though neither image/x-icns. Just selected the one most frequently seen on the first Google results page. BTW, x- prefixes are deprecated.

dgelessus commented 4 years ago

I'm currently working on a spec for this format and will make a PR when it's ready.