From cde95c7499f3d76496da2e938658deff6f0b20e6 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Wed, 26 Oct 2016 14:49:42 +0100 Subject: [PATCH] Add correction to generate photo ids without leading zero --- _scripts/generate-gallery.php | 1 + _scripts/photo-ids.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/_scripts/generate-gallery.php b/_scripts/generate-gallery.php index 00d9f62..324f969 100644 --- a/_scripts/generate-gallery.php +++ b/_scripts/generate-gallery.php @@ -58,6 +58,7 @@ $oConsole foreach (glob($sDir . '/*.[jJ][pP][gG]') as $i => $sFile) { // Generate id from file contents $sId = substr(sha1_file($sFile), 0, 7); + $sId[0] = $sId[0] == '0' ? '1' : $sId[0]; $oOutput->write('' . $sId . ''); // Parse selected EXIF data diff --git a/_scripts/photo-ids.php b/_scripts/photo-ids.php index 51dcfb3..7f35236 100644 --- a/_scripts/photo-ids.php +++ b/_scripts/photo-ids.php @@ -4,7 +4,8 @@ if (!isset($argv[1]) || !is_dir($argv[1])) { } $sPath = realpath($argv[1]); foreach (glob($sPath . '/*.jpg') as $sFile) { - $sId = substr(sha1_file($sFile), 0, 7); + $sId = substr(sha1_file($sFile), 0, 7); + $sId[0] = $sId[0] == '0' ? '1' : $sId[0]; $sBasename = basename($sFile, '.jpg'); printf("%s => %s\n", $sBasename, $sId); $sNewFile = str_replace($sBasename, $sId, $sFile);