# Re: Metadata 0.2

**URL:** <https://www.ruby-forum.com/t/re-metadata-0-2/114702>\
**Category:** Ruby\
**Created:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702 "2007-09-17T13:24:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702/1 "2007-09-17T13:24:31Z")

</div>

On 9/13/07, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any chance this could be expanded to add FLAC and OGG support?
> 
> ## Thanks!
> 
> Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [http://konrad.sobertillnoon.com/](http://konrad.sobertillnoon.com/)

Done! Along with a preliminary list of supported formats and some  
cleanup.  
Thanks for the request!

tarball: [http://dark.fhtr.org/repos/metadata/metadata-0.2.tar.gz](http://dark.fhtr.org/repos/metadata/metadata-0.2.tar.gz)  
git: [http://dark.fhtr.org/repos/metadata/](http://dark.fhtr.org/repos/metadata/)

Changelog:

README:  
\* added flacinfo, wmainfo, mp4info and ogginfo to the list of  
dependencies  
\* prelim list of supported formats  
lib/metadata/extract.rb:  
\* .ps.gz support  
\* list archive contents  
\* remove null fields from output  
\* support for flac and ogg  
\* untested support for wma and m4a  
\* Audio.Bitrate now in kbps to match shared-filemetadata-spec

## Description

This package `Metadata' comes with a library called `metadata’ and  
a small program called `mdh’.

The library probes files for their metadata (e.g. jpeg dimensions  
and camera make, mp3 artist, pdf word count) and returns the metadata  
as a Hash.

Mdh can print out file metadata as YAML and package the metadata  
with the file.

This package has many dependencies since there is no single universal  
metadata header format that all files use. Blame resource forks,  
filename  
extensions, bags of bytes and mimetypes.

## Usage

# print out metadata header

mdh -p myfile.jpg

# create myfile.jpg.mdh, which consists of metadata header +

myfile.jpg  
mdh myfile.jpg

# print out metadata header from mdh file

mdh -e -p myfile.jpg.mdh

# strip out metadata header from mdh file and save it to myfile.jpg

mdh -e myfile.jpg.mdh

irb\> Metadata.extract(‘myfile.jpg’)  
irb\> Metadata.extract\_text(‘myfile.jpg’)  
irb\> Pathname.new(“myfile.jpg”).metadata

## List of supported formats

Audio:  
Successfully tested with:  
mp3, flac, ogg, wav  
Should also work:  
wma, m4a

Video:  
What you manage to make mplayer play, which can be just about  
anything.  
Then again, missing title and author data, etc. (do videos even have  
those?)  
Successfully tested with:  
wmv, mov, divx, xvid, flv, ogm, mpg

Images:  
Should handle pretty much anything (apart from XCF and ORF.)  
Successfully tested with:  
jpeg, png, gif, nef, dng, crw, pef, psd

Documents:  
Successfully tested with:  
pdf, ppt, odp, sxi, ps, ps.gz, html, txt  
Should work:  
- OpenOffice docs work to some degree (personally, I’m using unoconv  
to  
convert OO docs to temp PDFs for the text & dimensions extraction,  
so  
those bits of data are missing.)  
- MS Office docs to some degree (ppt at least, doc and xls should  
work too,  
dimensions missing due to the above temp PDF -thing.)

Others:  
Whatever extract spits out on the five or six bits of metadata I’m  
using  
from it. Archive contents at least.

## Requirements

- Ruby 1.8

- Tons of metadata extraction programs and libs,  
list of gems:  
flacinfo-rb  
wmainfo-rb  
MP4info  
list of debian packages:  
dcraw  
libimlib2-ruby  
extract  
libimage-exiftool-perl  
poppler-utils  
mplayer  
html2text  
imagemagick  
unhtml  
pstotext  
antiword  
catdoc  
shared-mime-info  
vorbis-tools

- You do want to install the latest versions of dcraw and  
shared-mime-info to be able to handle camera raw images.  
[http://cybercom.net/~dcoffin/dcraw/](http://cybercom.net/~dcoffin/dcraw/)  
[shared-mime-info](http://freedesktop.org/wiki/Software/shared-mime-info)

- Python + chardet library  
[http://chardet.feedparser.org/](http://chardet.feedparser.org/)

## Install

De-compress archive and enter its top directory.  
Then type:

($ su)  
# ruby setup.rb

These simple step installs this program under the default  
location of Ruby libraries. You can also install files into  
your favorite directory by supplying setup.rb some options.  
Try “ruby setup.rb --help”.

## License

Ruby’s

Ilmari H. \<ilmari.heikkinen gmail com\>

> **[fhtr](http://fhtr.blogspot.com)**
>
> art with code

---

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [September 17, 2007, 1:25pm UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702/2 "2007-09-17T13:25:01Z")

</div>

Hi Ilmari!

quoth the Ilmari H.:

> ```
> * added flacinfo, wmainfo, mp4info and ogginfo to the list of
> dependencies
> 
> ```

Cool, you were able to use a couple of my libraries (be afraid  
people…).

> Video:  
> What you manage to make mplayer play, which can be just about anything.  
> Then again, missing title and author data, etc. (do videos even have  
> those?) Successfully tested with:  
> wmv, mov, divx, xvid, flv, ogm, mpg

Just wanted to mention that despite the name, wmainfo will parse  
anything  
wrapped in an ASF audio/video container format[0], so, you could use it  
to  
parse wmv movies as well if your user didn’t have mplayer installed.

[0] [Advanced Systems Format - Wikipedia](http://en.wikipedia.org/wiki/Advanced_Systems_Format)

> Ilmari H. \<ilmari.heikkinen gmail com\>  
> [http://fhtr.blogspot.com](http://fhtr.blogspot.com)

Thanks for the code, and have a good one,  
-d

---

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [October 1, 2010, 1:15am UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702/3 "2010-10-01T01:15:25Z")

</div>

Ilmari H. wrote:

> On 9/13/07, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Any chance this could be expanded to add FLAC and OGG support?
> > 
> > ## Thanks!
> > 
> > Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [http://konrad.sobertillnoon.com/](http://konrad.sobertillnoon.com/)
> 
> Done! Along with a preliminary list of supported formats and some  
> cleanup.  
> Thanks for the request!
> 
> tarball: [http://dark.fhtr.org/repos/metadata/metadata-0.2.tar.gz](http://dark.fhtr.org/repos/metadata/metadata-0.2.tar.gz)  
> git: [http://dark.fhtr.org/repos/metadata/](http://dark.fhtr.org/repos/metadata/)

Hi, these links are dead. Does this package still exist anywhere? Is it  
available as a gem?  
Thanks,  
Dan

> ## Description
> 
> This package `Metadata' comes with a library called `metadata’ and  
> a small program called `mdh’.
> 
> The library probes files for their metadata (e.g. jpeg dimensions  
> and camera make, mp3 artist, pdf word count) and returns the metadata  
> as a Hash.
> 
> Mdh can print out file metadata as YAML and package the metadata  
> with the file.
> 
> This package has many dependencies since there is no single universal  
> metadata header format that all files use. Blame resource forks,  
> filename  
> extensions, bags of bytes and mimetypes.

---

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [October 1, 2010, 1:49am UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702/4 "2010-10-01T01:49:25Z")

</div>

John W Higgins wrote:

> On Thu, Sep 30, 2010 at 4:15 PM, Dan T.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:
> 
> > Ilmari H. wrote:
> > 
> > > On 9/13/07, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > Hi, these links are dead. Does this package still exist anywhere? Is it  
> > available as a gem?  
> > Thanks,  
> > Dan
> 
> You really are going to take the time to open up a 3+ year old thread on  
> a  
> mailing list (for the second time by the way) as opposed to typing “ruby  
> metadata” into google?
> 
> John

My post did not show up (on [ruby-forum.com](http://ruby-forum.com)) the first time.  
All that google shows are these same dead links.

---

<div class="post-metadata">

**Author:** ![Ilmari\_H](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a587f6/32.png) [@Ilmari\_H](https://www.ruby-forum.com/u/Ilmari_H)\
**Post date:** [October 1, 2010, 1:47am UTC](https://www.ruby-forum.com/t/re-metadata-0-2/114702/5 "2010-10-01T01:47:28Z")

</div>

On Thu, Sep 30, 2010 at 4:15 PM, Dan T.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Ilmari H. wrote:
> 
> > On 9/13/07, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Hi, these links are dead. Does this package still exist anywhere? Is it  
> available as a gem?  
> Thanks,  
> Dan

You really are going to take the time to open up a 3+ year old thread on  
a  
mailing list (for the second time by the way) as opposed to typing “ruby  
metadata” into google?

John
