Databases Reference
In-Depth Information
+---------+---------------------------------------------+
| chapter | title |
+---------+---------------------------------------------+
| 1 | Compiling and Using MySQL Plugins |
| 7 | Practical Full-Text Parsers |
| 9 | HTML Storage Engine - reads and writes |
| 10 | TOCAB Storage Engine - implementing indexes |
+---------+---------------------------------------------+
4 rows in set (0.00 sec)
An Image Metadata processor
In the previous examples we have discussed full-text parser plugins that were actually
doing the parsing—extracting words from a text. But as we have seen in Chapter 6, a
full-text parser plugin does not necessarily have to do that. Only "tokenizer" plugins
do. In this example we will create an "extractor" plugin—a plugin that merely converts
the data to plain text and lets MySQL parse it with a built-in parser.
As many know, digital cameras store inside an image file the metadata that contains
various details about the photo. It is stored using a format called Exif (Exchangeable
image file format).
This full-text parser plugin will take the image filenames from the database, parse
the Exif data, and allow MySQL to index it. In other words, one can INSERT rows
with filenames in the table, but MATCH AGAINST() will search in the Exif metadata
of these images!
How to access Exif data
To extract the image metadata we will use the libexif library. It is included in most
Linux distributions, and it has also been ported to Mac OS X, Windows, FreeBSD,
Solaris, and other operating systems. The binaries and the source code can be found
at http://libexif.sourceforge.net/ . We will need to tell the compiler to
link our plugin with this library. For gcc this is done by adding -lexif to the
command line.
The libexif library has many different objects and types, and a lot of different
functions that manipulate them. But we are only interested in reading (not writing)
all (not selected) values of Exif tags. For this very limited task we need to know just a
few libexif functions:
Function
Description
exif_data_new_from_file(
const char *path)
Creates an ExifData object and fills it
with the data from an image file.
Search WWH ::




Custom Search