New gallery coding almost complete

I have spent several hours this past week building the upload code, the resampling code – that was a giant task – and the watermarking routine. I have most of the difficult coding behind me and now I just have some basic html and logic left in addition to putting it all together. I should have a bare bones gallery up and running in the next day or so.

How To: ExifTool php array – example code

php logo
/*==========================================================================
	read exif from exiftool from image into raw array
	two different ways to do it here depending on what you like
============================================================================*/
//exec('exiftool -s ' . '"' . $path_to_image . '"', $exif_raw_array);   
// note the -s flag returns tags with no spaces -n removes data formatting will work with either or none

exec('exiftool -s -n -Orientation -ImageWidth -ImageHeight -Title -ImageDescription -Keywords -Copyright -Artist -Make -Model -LensModel -FocalLength -FocalLengthIn35mmFormat -ShutterSpeedValue -ApertureValue -ISO -DateTimeOriginal -City -State -Country -Location -GPSSpeed -GPSAltitude -GPSLatitude -GPSLongitude ' . '"' . $path_to_image . '"', $exif_raw_array);

/*==========================================================================
	extract tagname and tagname value from raw array
============================================================================*/
// note var_dump(exif_raw_array) to visualize what needs to be done
foreach ($exif_raw_array as $key => $value)  {
	
$string_length_of_value_field = strlen($value); // need string length for calculation below
$position_of_colon = strpos($value, ':'); //get the position of the colon to use in calculation below


$exiftool_tagname = substr($value, 0, $position_of_colon); // shorten the full string starting at position 0 and ending at the colon
$exiftool_tagname = ltrim($exiftool_tagname); // trim any white space on the left that may exist
$exiftool_tagname = rtrim($exiftool_tagname); // trim any white space on the right that may exist
// done - now have $exiftool_tagname extracted by itself


// same technique as above just extracting the other end of the string
$exiftool_tagname_value = substr($value, ($position_of_colon+1), ($string_length_of_value_field-$position_of_colon));
$exiftool_tagname_value = ltrim($exiftool_tagname_value);
$exiftool_tagname_value = rtrim($exiftool_tagname_value);
// done - now have $exiftool_tagname_value extracted by itself


/*==========================================================================
	enter variables into exiftool_final_array with predictable fields
============================================================================*/
$exiftool_final_array[$exiftool_tagname] = $exiftool_tagname_value;


/*==========================================================================
	end of exif_raw_array loop
============================================================================*/
}

/*==========================================================================
	destroy exif_raw_array - no need to keep in memory
============================================================================*/
unset($exif_raw_array);
/*==========================================================================
	done - new clean array is ready to use - try var_dump($exiftool_final_array)
	to see
============================================================================*/

Building my own photo gallery site from scratch

code for upload routine
code for upload routine

So after struggling with SEO and photo gallery sites for years, and I’ve tried them all, I decided that if I think I could do a better job at building an online photo gallery site, then I should either “put up” or “shut up”. I am going the “put up” route. I already have a server built that lives in Fremont, Ca. I already installed a robust Linux environment where I control every bit. I then pointed my oldest domain to all this (I think I first put it online in 1998), and set off on a journey that I may regret… or not. We’ll see. Today I wrote the login code to protect the back-end of my future site. Now I am working on the code that will upload new images. Stay tuned.