README.md in file_data-5.0.0 vs README.md in file_data-5.2.0

- old
+ new

@@ -2,17 +2,32 @@ ========= [![Build Status](https://travis-ci.org/ScottHaney/file_data.svg?branch=master)](https://travis-ci.org/ScottHaney/file_data) [![Coverage Status](https://coveralls.io/repos/github/ScottHaney/file_data/badge.svg?branch=master)](https://coveralls.io/github/ScottHaney/file_data?branch=master) [![Code Climate](https://codeclimate.com/github/ScottHaney/file_data/badges/gpa.svg)](https://codeclimate.com/github/ScottHaney/file_data) +[![Gem Version](https://badge.fury.io/rb/file_data.svg)](https://badge.fury.io/rb/file_data) Ruby library that reads file metadata. -Current support +The api provides a basic usage and an advanced usage. The basic usage will reopen and reparse the file every time it is called which is no problem when reading a single value but can be a performance drain for multiple values. The advanced usage allows the user to grab more than one value without having to read the file more than once. -* Exif: Only jpeg files are supported and FlashPix extensions are not supported +## Basic Usage +```ruby +filepath = '...' # Path to a jpeg or mpeg4 file + +# Get the date when the file content originated. When a photo was taken, when a movie was recorded, etc +FileData::FileInfo.origin_date(filepath) + +# Get the date when the file was considered to be created. This is usually tied in some way to when the file itself was created on a disk somewhere (not usually as useful as origin date) +FileData::FileInfo.creation_date(filepath) +``` + +## Advanced Usage + +Varies by file format type. Currently there are low level classes for parsing exif and mpeg4 metadata + ## Exif documentation Exif data is hierarchical and consists of tag/value pairs. The first level is whether or not the tag applies to the image or the image's thumbnail. Next a tag may be one of several sections and within the section it will have a unique numeric value. So given this terminology a unique key for an exif tag would be something like image/section1/123 for a tag that applies to the image in section 1 with a tag id of 123. To read exif data a stream of the jpeg data should be used as input. For performance reasons all of the data that is desired should be extracted in a single method from FileData::Exif. All methods will manipulate the stream position after they are called and the user should not count on the stream position being at a specific location after a FileData::Exif method call. @@ -219,6 +234,19 @@ { 1 => :Interoperability_Index } ``` +## Mpeg4 documentation +```ruby + +filepath = '...' # path to an mpeg4 file +File.open(filepath, 'rb') do |stream| + parser = FileData::MvhdBoxParser # class that parses the box you want + method = :creation_time # attribute to get from the parse result + box_path = ['moov', 'mvhd'] # path to get to the box that you want + + # final result that you are looking for + result = FileData::Mpeg4.get_value(stream, parser, method, *box_path) +end +```