Giter VIP home page Giter VIP logo

magickit's Introduction

MagicKit.framework

MagicKit.framework is an easy-to-use wrapper around the libmagic file identification library. It provides a high-level Objective-C interface and deals in Foundation types (NSString, NSData, et al).

MagicKit.framework is available for both OS X (as a framework) or iOS as a static library with header files. MagicKit.framework consists of a master class, GEMagicKit, and an intermediary class, GEMagicResult. The GEMagicKit master class has six class methods, listed below in descending order of convenience.

+ (GEMagicResult *)magicForFileAtPath:(NSString *)path;
+ (GEMagicResult *)magicForFileAtURL:(NSURL *)aURL;
+ (GEMagicResult *)magicForData:(NSData *)data;

+ (GEMagicResult *)magicForFileAtPath:(NSString *)path decompress:(BOOL)decompress;
+ (GEMagicResult *)magicForFileAtURL:(NSURL *)aURL decompress:(BOOL)decompress;
+ (GEMagicResult *)magicForData:(NSData *)data decompress:(BOOL)decompress;

These methods all return the GEMagicResult intermediary class. The GEMagicResult class has four properties. These are mimeType, description, uniformType and uniformTypeHierarchy. the first three properties are NSString objects, the final returns an NSArray object.

Example MIME types include:

  • application/xml; charset=us-ascii
  • video/x-msvideo; charset=binary

Or a textual description, respectively:

  • XML document text
  • RIFF (little-endian) data, AVI, 624 x 352, 23.98 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz))

Finally, uniformType and uniformTypeHierarchy return Uniform Type Identifiers for the relevant file/data. The type hierarchy is an array of types that the given file conforms to.

GEMagicKit can also decompress compressed files and hence attempt to determine the contents within.

MagicKit.framework is MIT-licensed. libmagic is BSD-licensed.

magickit's People

Contributors

jmah avatar aidansteele avatar arix avatar mz2 avatar sdevore avatar jcarlson23 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.