Thursday, March 3, 2011

Thumbnail images and php

Ever since I found out that photographs from my digital camera contain extra information, I have been trying to figure out how to exploit it. I like the idea of information about an image being contained in the image. In particular, the actual date that a photograph is taken is often lost when I am copying and cleaning up. Sometimes the creation date is the date that I copied it from the camera. For example, my last trip to Colorado resulted in lots of landscape images. I had to label one of them "notsure.jpg" because somehow, in my sorting, it lost its connection with the others. But I can find the "date taken" and its nearest neighbors in time will help me find its location.

Creating a thumbnail from the EXIF data (using exif_thumbnail()) caused a black bar to appear above and below my image.This I could not live with. After an hour or two of intense searching, I found some alternatives but I could not get the image to be displayed. Mostly, the name of the file would appear in its place (in Firebug, one can see that this is the alt value for the image).

By google'ing the word "gibberish", I found the answer. (By gibberish, I mean that the code was printing out the image in text format rather than a nice photo.) Responses to the questioners spoke about the header, white space and separate files. The following code produces a smaller image than the original if I call it from another php file. The only thing I need to figure out now is how to make the name of the file a variable for input.

header('Content-type: image/jpeg');
$image = new Imagick('landscape_gallery/skyline_drive/tr_valley5.jpg');
$image->thumbnailImage(100, 0);
echo $image;
?>

Just found this working example for image gallery. I am sure I was at this website yesterday but I did not understand the goal of the code. When the code is activated ( I have an href link from another file), it creates a file structure in the directory in which it is physically located, including an html file and subdirectory with thumbnails. ONLY AFTER this is done, can I go back and open the html file and display the images. These display the original image (on a new page) when clicked. Since I know what the name of the html file is, I can hard code the link to it (even if its contents are different).

Wednesday, March 2, 2011

Natural selection

I have never been a good theorist. I can't read a book and then apply its principles to a problem that I am trying to solve. I am more like nature, I try many different applications before the one that solves my problem makes it into my program. Sometimes I take parts of one application and add it to another. Sometimes I create a new one consisting mostly of spare parts. I guess you could call me a junkyard mechanic.

Is this an efficient way to work? A hundred years ago it would not be. But the internet and contributions of many people offer a smorgasbord of options and solutions. Some patience and a good internet  connection are all I need.

This is just a collection of the bookmarks I created just this week. I am truly grateful to the people who publish their work for all to see.
What am I trying to do? I am working on a web travel journal. I want to display images and add tags to the metadata (exif). I also use a camera set to Dutch time and need to change the dates on the photographs to the location time. This needs html, php, xml and javascript. CSS will provide the finishing touches. I also want to create a family ancestry website, for which I'll need to create metadata for scanned photographs. Stay tuned.