Thursday, October 21, 2010

Showing image EXIF data with PHP

Today I had an issue that I didn't know how to solve, until I searched the web. I wanted to pull the EXIF data that images contain and display it on the page. Mainly I wanted to show any copyright data.

I found this blog post on which helped me a lot. Looking at the post, I came up with the below to show the copyright of an image:

$image = "/path/to/image.jpg";
$exif = exif_read_data($image, 0, true);
foreach ($exif as $key => $section) {
    foreach ($section as $name => $val) {
        if ($name == "Copyright") {
            echo "$val";

For the exif_read_data function to work, if you're using Windows, you need to go into your php.ini file, make sure both php_mbstring.dll and php_exif.dll are not commented out, and make sure that php_mbstring.dll is listed above php_exif.dll so it's loaded first.

If you wanted to show all of the image's EXIF data, in the blog post linked to above they show you how to do that.

Wednesday, October 06, 2010

Cool css gradient generator

Here's a cool tool you can use to create gradients for your site, called Ultimate CSS Gradient Generator from ColorZilla. It's a powerful Photoshop-like CSS gradient editor that you can use right in your web browser. But make sure to view the site in a recent version of Firefox, Chrome, or Safari to see the results though.