Skip to main content

Helps to find structured metadata from a given file.

Project description


file-metadata is a python package that aims to analyze files and find metadata that can be used from it.


Before installing file-metadata, a few dependencies need to be installed. For Ubuntu, these can be installed with:

$ sudo apt-get install perl openjdk-7-jre python-dev pkg-config \
> libfreetype6-dev libpng12-dev liblapack-dev libblas-dev gfortran \
> cmake libboost-python-dev libzbar-dev

Next, use pip to install the library. To install the latest stable version, use:

$ pip install file-metadata

To get development builds from the master branch of the github repo, use:

$ pip install --pre file-metadata


To use the package, you first need a file which can be any media file.

Let us first download an example qrcode from commons wikimedia:

$ wget -O qrcode.jpg

And now, let us create a File object from this:

>>> from file_metadata.generic_file import GenericFile
>>> qr = GenericFile.create('qrcode.jpg')

Notice that when creating the file, the class automatically finds the best type of class to analyze the file. In this case, it auto detecs that the file is an image file, and uses the ImageFile class:

>>> qr.__class__.__name__

Now, to find possible analysis routines supported for the file, help(qr) can be checked. All routines beginning with analyze_ perform analysis. As the example we have is a qrcode, let us use analyze_barcode_zxing():

>>> qr.analyze_barcode_zxing()
{'zxing:Barcodes': [{'data': '',
   'format': 'QR_CODE',
   'points': [(50.0, 316.0), (50.0, 52.0), (314.0, 52.0), (278.0, 280.0)],
   'raw_data': ''}]}

Which tells us the bounding box of the barcode (points) and also the data ( It also mentions that the format of the barcode is QR_CODE.

Similarly, to check the mimetype, the analysis routing analyze_mimetype() can be used:

>>> qr.analyze_mimetype()
{'File:MIMEType': 'image/jpeg'}

To perform all the analyze routines on the image, the analyze() method can be used. It runs all the analysis routines on the file and gives back the merged result:

>>> qr.analyze()



To test the code, install dependencies using:

$ pip install -r test-requirements.txt

and then execute:

$ python -m pytest


To pull the latest docker image use:

$ docker pull pywikibotcatfiles/file-metadata
Supported tags and respective Dockerfile links:

For more information about this image and its history, please see pywikibotcatfiles/file-metadata (on docker-hub). This image is updated via push to the pywikibot-catfiles/docker-file-metadata GitHub repo or the pywikibot-catfiles/file-metadata GitHub repo (by Triggering builds through the Travis CI API).

Build status


This package has been derived from pywikibot-compat. Specifically, the script which can be found at pywikibot-compat/ These packages were created by DrTrigon who is the original author of this package.


This code falls under the MIT License. Please note that some files or content may be copied from other places and have their own licenses. Dependencies that are being used to generate the databases also have their own licenses.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

file-metadata-0.2.0.tar.gz (631.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page