summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-06-18 19:36:37 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-06-18 19:36:37 +0000
commit764ad0eb8718d3611956402725d6a4615f688d8a (patch)
treef081ccc0dcb31164c49c2fb4c1e2429c38aea8d9 /phpfspot.class.php
parent02fa42f4fa425887713b1df57ed17a48f2b83c6e (diff)
issue10, fixed on-demand thumbnail generation
git-svn-id: file:///var/lib/svn/phpfspot/trunk@108 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php59
1 files changed, 24 insertions, 35 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index cf0fa25..2ffec5f 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -536,50 +536,39 @@ class PHPFSPOT {
} // check_config_table
- public function gen_thumbs($idx = 0, $fromcmd = 0)
+ public function gen_thumb($idx = 0, $fromcmd = 0)
{
- if(!$idx) {
- /* get all available photos */
- $all = $this->getPhotoSelection();
- }
- else
- $all = Array($idx);
-
- foreach($all as $photo) {
+ $details = $this->get_photo_details($idx);
- $details = $this->get_photo_details($photo);
+ $full_path = $this->translate_path($details['directory_path']) ."/". $details['name'];
+ $file_md5 = md5_file($full_path);
- $full_path = $this->translate_path($details['directory_path']) ."/". $details['name'];
- $file_md5 = md5_file($full_path);
+ if($fromcmd) print "Image [". $idx ."] ". $details['name'] ." Thumbnails:";
- if($fromcmd) print "Image [". $photo ."] ". $details['name'] ." Thumbnails:";
-
- /* if the file hasn't changed there is no need to regen the thumb */
- if($file_md5 == $this->getMD5($photo)) {
- if($fromcmd) print " file has not changed - skipping\n";
- continue;
- }
-
- /* set the new/changed MD5 sum for the current photo */
- $this->setMD5($photo, $file_md5);
+ /* if the file hasn't changed there is no need to regen the thumb */
+ if($file_md5 == $this->getMD5($idx)) {
+ if($fromcmd) print " file has not changed - skipping\n";
+ return;
+ }
- $resolutions = Array(
- $this->cfg->thumb_width,
- $this->cfg->bubble_width,
- $this->cfg->photo_width
- );
+ /* set the new/changed MD5 sum for the current photo */
+ $this->setMD5($idx, $file_md5);
- /* create thumbnails for the requested resolutions */
- foreach($resolutions as $resolution) {
- if($fromcmd) print " ". $resolution ."px";
- $this->create_thumbnail($full_path, $resolution);
- }
-
- if($fromcmd) print "\n";
+ $resolutions = Array(
+ $this->cfg->thumb_width,
+ $this->cfg->bubble_width,
+ $this->cfg->photo_width
+ );
+ /* create thumbnails for the requested resolutions */
+ foreach($resolutions as $resolution) {
+ if($fromcmd) print " ". $resolution ."px";
+ $this->create_thumbnail($full_path, $resolution);
}
- } // gen_thumbs()
+ if($fromcmd) print "\n";
+
+ } // gen_thumb()
private function getMD5($idx)
{