Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/manveru/ffi-magic
- Owner: manveru
- License: mit
- Created: 2010-06-13T22:53:16.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T21:58:17.000Z (almost 7 years ago)
- Last Synced: 2024-04-25T13:40:55.189Z (9 months ago)
- Language: Ruby
- Homepage:
- Size: 231 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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"
```