❯~/pixelastic

A little introduction to image metadata

For the project I'm working on, I have to save numerous[ ](http://en.wikipedia .org/wiki/International_Press_Telecommunications_Council)data in image files. The metadata I have to write can be in different languages and uses different encoding (mainly French, English, Spanish and Chinese).

A little history

There is mainly three formats to store data inside an image. The main one is called EXIF, its main goal is to store techical data about the image like the operture, is the flash was fired, the resolution, the iso settings and so on.

The second one is called IPTC. Its main goal was to store more subjective information about the file like its description, its author, copyright informations, etc.

IPTC is an old standard and is more or less replaced with XMP nowadays becuase of numerous restrictions on it (mainly no UTF8 and internationalisation support). (A later version named IPTC-IIM was created to correct some of the minor restrictions, but it was still far from perfect).

It is now more or less replaced with XMP. XMP is based on XML and uses the Dublin Core tags. It is the future of metadatas because its structure allows it to be extended.

And now, the problems

The problem is that with this three formats, it is quite difficult to know where to store or read the information we want. Additionnaly the XMP support is not very mainstrean on the software, even Adobe (creator of the XMP format) does not support it totally accross its products.

A Metadata Working Group had been formed to tell all the good people of Metadata-land what to do when faced with an image filled with metadatas. They wrote a recommendation guide telling us how to handle reconciliation (a same information is stored in more than one format, but with different values) and make our software the most compatible with existing software.

What about me?

That's when I can talk about me again. I'm working on a project where I have to read a full database of images, parse their metadatas, store them in a database, and build an interface to search accross the database based on criterias like keywords, author, etc.

I also have to handle the web side of this and allow for easy creation of thumbnails, large and medium version with metadatas correctly written inside the file.

The admin panel should also allow anyone to modify one file metadata and rewrite it back into the file as well as inside the database.

This is kind of a big project for me, it's been 2.5 months that I'm on it and I had to learn everything from scrath: all the historical stuff, format specs, recommendation as well as Coldfusion -the language the app is built on-

I've learn a lot until now and I still have 15 more days to finish it. The main app is almost finished (I just have to polish on some edge cases) and then I'll have to integrate it in the existing admin panel.

Selecting node based on namespace in xPath

I'm used to XPath, I use it in my Javascript dev (jQuery) has well as in my cakePHP dev (the Set::extract() method), and I've always thought it was really fast, powerful and readable.

Today I had to parse a real-world XML file, and I discovered that when dealing with namespaces, all became suddenly much more difficult in the XPath world.

Here is my xml source (shortened for the sake of clarity):

<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
 <x:xmpmeta xmlns:x="adobe:ns:meta/">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

 <rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
 <dc:creator>Igor Gosstroff</dc:creator>
 <dc:description xml:lang="x-default">Awesome picture</dc:description>
 </rdf:Description>

 <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
 <xmp:Rating>4</xmp:Rating>
 </rdf:Description>

 </rdf:RDF>
 </x:xmpmeta>                                            
<?xpacket end="w"?>

I wanted to select the first <rdf:Description> (Dublin Core).

First of all, you have to know that you can't do //rdf:description, you have to use a special syntax because the: is a reserved character. The solution is using the name() method: //*[name()='rdf:Description'].

It will return both rdf:Description nodes. I can easily get the one i'm interested in by doing //*[name()='rdf:Description'][1] but I would have liked to use a much more simple syntax and select the one with an xmlns:dc attribute.

And I did not find out how to do that. All the syntaxes I tried either returned nothing, threw and exception and even crash my app once.

I finally found a devious way to find it. I search for any xmlField whose namespace uri was http://purl.org/dc/elements/1.1/ and then get its parent. I still feel like its a dirty hack but I've allready spent too much time on it, so it will be enough for now.

//*[namespace-uri()='http://purl.org/dc/elements/1.1/'][1]/../

Safari input focusing problem

I just ran into a strange behavior on Safari 3 (Win). I'm not quite sure what caused this problem, but I tracked it down to one CSS rule.

The thing was that I had an input field that moved whenever I tried to focus it. It jump 3 pixels up whenever I gave him focus. I had never seen that before.

I finally managed to track it down to the padding:2px 0px 5px 0px; declaration. I exploded it in four (-top, -right, -bottom and -left) and it seemed that it was the padding-bottom:0px that cause the bug.

I finally rewrote my css (in three lines instead of one) and moved to other things.

I post it here as a reminder, and hope it could help someone.

Freelancing, I miss you

Well, it's been one month and a half now that I've put my freelance activites on hold. I'm in contract with a big company to develop an internal application.

The purpose of the application is really interesting, the guy I'm working with is too, but the language I have to use as well as the all-administrative thing of big companies like that is... well... let's just say I LOVE being a freelancer PHP developper.

One more month and a half and it will be over. I allready have learn a lot about metadatas in general and particularly Exif, Iptc and XMP. I've also learned a little about Coldfusion. Enough to know that I won't work with that language again, unless I'm forced too.

In the remaining week, I'll also learn EXTJs, and this part seems promising. I guess leaving jQuery and its easy syntax will be hard at first, but all the data handling of EXTJs seems really powerful.

Anyway, when that contract will be over, I'll be back to Caracole and I have so many ideas of features and whole websites that I want to create...

I would like to make the admin panel of Caracole the one thing an administrator would have to check to see if everything is going well on its website. I allready have an extended PHPInfo() highlighting possible misconfiguration but I want to push that further by integrating Google Analytics, checking the Gmail inbox associated as well as integrating the PHPSec library.

In the future I also plan on creating a photography website for Street Art and graffitis, with gelocalisation, metadatas saving of the author and place, possibility to upload photo directly from a mobile phone, etc

The old ideas about my own personal website, a quizz website, or one for rating driver's ed are still in my mind. Wait and see.

Configuring a .fr with Dreamhost

Hosting a website on a .fr is a little harder than a simple .com. The Afnic (registry for the .fr domains) makes a check whenever you change the DNS of your domain to make sure the new DNS can accept the domain.

They run a tool named ZoneCheck to do that. This tool will request the new DNS server to test if they can accept the .fr. The problem is that they make a request on the port 53, which is not open on Dreamhost and thus the test fail and the Afnic refuse to let you change your DNS.

The alternative is to not change you DNS, and keep the default one of your registrar, but manually edit the zones and copy the zones defined in your dreamhost panel (In Domains > Your domain > DNS, at the bottom of the page) into your zones.

The most important part is modifying the default A entry to the IP of your dreamhost server. You should do the same for the www A entry to.

Create a mysql A entry and a ftp A entry if you want to use both ftp.domain.com and mysql.domain.com.

I also changed the MX record to the google one, as well as creating a CNAME webmail.