Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/manveru/ffi-magic

Ruby FFI binding for libmagic
https://github.com/manveru/ffi-magic

Last synced: 2 months ago
JSON representation

Ruby FFI binding for libmagic

Awesome Lists containing this project

README

        

# Ruby FFI bindings for libmagic

## Usage

```ruby
>> require 'ffi-magic'
=> true
>> magic = Magic.new
=> #>
>> magic.file('spec/magic.png')
=> "PNG image data, 100 x 67, 8-bit/color RGB, non-interlaced"
>> magic.flags = Magic::MIME_TYPE
=> 16
>> magic.file('spec/magic.png')
=> "image/png"
```

### Getting the MIME Type

```ruby
magic = Magic.new(Magic::MIME)
=> #>
>> magic.file('spec/magic.png')
>> => "image/png; charset=binary"
```