[Linpha-cvs] SF.net SVN: linpha: [4842] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2008-01-31 12:36:16
|
Revision: 4842 http://linpha.svn.sourceforge.net/linpha/?rev=4842&view=rev Author: bzrudi Date: 2008-01-31 04:27:25 -0800 (Thu, 31 Jan 2008) Log Message: ----------- more improvements in maps plugin Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.exiftool.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.pjmt.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/plugins/maps/module.maps.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/ChangeLog 2008-01-31 12:27:25 UTC (rev 4842) @@ -1,4 +1,12 @@ - +2008-01-31 bzrudi + * Maps plugin + - all DBs should work now (untestet) + - PJMT and exiftool should work now + - add admin options to enable/disable geodata and autoimport + - code cleanups + - still work in progress + - btw - installer looks fine + 2008-01-30 flo * installer - improved layout Modified: trunk/linpha2/lib/classes/linpha.exiftool.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.exiftool.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -173,14 +173,13 @@ return $metaArray; } - /** * Save all MetaData to database * @param string $filename filename to parse for MetaData * @param string $md5sum md5sum of file * @param string $tag save EXIF, IPTC or XMP MetaData */ - function saveMetaData($filename, $md5sum, $tag) + public function saveMetaData($filename, $md5sum, $tag) { $dataArray = LinExifTool::readMetaDataFromFile($tag, $filename); @@ -325,7 +324,6 @@ } } - /** * Define array with allowed IPTC/XMP tags and human readable translation * @param none Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -1,257 +1,257 @@ <?php /* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** * This class provides a couple methods for image manipulation/creation * @package Image */ - + if(!defined('LINPHA_DIR')) { exit(1); } class LinImage { -public $error_msg; -public $output_file; + public $error_msg; + public $output_file; -public $photo_id, $cached_id; -public $isCached; -public $mode; -public $img_type, $org_width, $org_height, $rotate; + public $photo_id, $cached_id; + public $isCached; + public $mode; + public $img_type, $org_width, $org_height, $rotate; -private $src_file; -private $img_width, $img_height; -private $img_quality; -private $imageTool; + private $src_file; + private $img_width, $img_height; + private $img_quality; + private $imageTool; -/** - * constructor - */ -function __construct() -{ -} + /** + * constructor + */ + function __construct() + { + } -function setFileInformation() -{ - /** - * check for valid id - * and get img_type and rotate informations - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type, rotate, width, height " . + function setFileInformation() + { + /** + * check for valid id + * and get img_type and rotate informations + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type, rotate, width, height " . "FROM ".LIN_PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); - if( $query->EOF ) // not a single value returned - { - $this->error_msg = "wrong id supplied!"; - return false; - } - - $data = $query->FetchRow(); - - if( ! LinSql::photoIsAllowed( $data['id'] ) ) - { - $this->error_msg = "not permitted!"; - return false; - } - - if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) - { - $this->error_msg = "only images possible!"; - return false; - } + if( $query->EOF ) // not a single value returned + { + $this->error_msg = "wrong id supplied!"; + return false; + } - /** - * checke force parameter - */ - if( isset($_GET['force'] ) ) { - $this->force = true; - } else { - $this->force = false; - } + $data = $query->FetchRow(); - /** - * set additional informations - */ - $this->rotate = $data['rotate']; - $this->img_type = $data['img_type']; - $this->org_width = $data['width']; - $this->org_height = $data['height']; - $this->setCachedInfos(); - - /** - * check if file already exists OR if forced - */ - if( file_exists( $this->output_file ) AND !$this->force ) - { - $this->isCached = true; - } - else // !file_exists() OR $this->force - { - $this->isCached = false; + if( ! LinSql::photoIsAllowed( $data['id'] ) ) + { + $this->error_msg = "not permitted!"; + return false; + } - /** - * create subfolder if needed - */ - if( ! file_exists( dirname($this->output_file) ) ) - { - if( ! @mkdir( dirname($this->output_file) ) ) - { - $this->error_msg = "Cannot create folder ".dirname($this->output_file)." check permissions!"; - return false; - } - } + if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) + { + $this->error_msg = "only images possible!"; + return false; + } - /** - * use imagemagick or gdlib - */ - if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) - { - include_once(LINPHA_DIR.'/lib/classes/image/linpha.imagemagick.class.php'); - - $this->imageTool = new LinImageMagick(); - $this->imageTool->imagemagickPath = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; - } - else - { - include_once(LINPHA_DIR.'/lib/classes/image/linpha.gdlib.class.php'); - - $this->imageTool = new LinGDLib(); - $this->imageTool->imgType = $this->img_type; - } + /** + * checke force parameter + */ + if( isset($_GET['force'] ) ) { + $this->force = true; + } else { + $this->force = false; + } - $this->imageTool->imgQuality = $this->img_quality; - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - } - - return true; -} + /** + * set additional informations + */ + $this->rotate = $data['rotate']; + $this->img_type = $data['img_type']; + $this->org_width = $data['width']; + $this->org_height = $data['height']; + $this->setCachedInfos(); -/** - * set cached_id and output_file - * in image mode set also rotate, watermark, quality, ... - * and add an empty entry in the cache database - */ -function setCachedInfos() -{ - if($this->mode == 'thumb') - { - $this->cached_id = $this->photo_id; + /** + * check if file already exists OR if forced + */ + if( file_exists( $this->output_file ) AND !$this->force ) + { + $this->isCached = true; + } + else // !file_exists() OR $this->force + { + $this->isCached = false; - $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id,$this->img_type); - } - elseif($this->mode == 'img') - { - /** - * check additional settings - */ - /** - * max_width and max_height - */ - if(isset($this->overrideSettings['max_width']) && isset($this->overrideSettings['max_height'])) - { - $this->max_width = $this->overrideSettings['max_width']; - $this->max_height = $this->overrideSettings['max_height']; - } - else - { - $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; - $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; - } - - /** - * update rotate (printing, ...) if applicable (no else() !! ) - * the rotate value from the database is read earlier - */ - if(isset($this->overrideSettings['rotate'])) - { - $this->rotate = $this->overrideSettings['rotate']; - } - - /** - * watermark (true|false) - */ - if(isset($this->overrideSettings['watermark'])) - { - $this->watermark = $this->overrideSettings['watermark']; - } - else - { - /** - * @todo place need_watermark() here - */ - $this->watermark = 0; - } - - /** - * quality - */ - if(isset($this->overrideSettings['quality'])) - { - $this->img_quality = intval($this->overrideSettings['quality']); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - } - else - { - $this->img_quality = intval($GLOBALS['linpha']->sql->config->value['sys_style_image_quality']); - } + /** + * create subfolder if needed + */ + if( ! file_exists( dirname($this->output_file) ) ) + { + if( ! @mkdir( dirname($this->output_file) ) ) + { + $this->error_msg = "Cannot create folder ".dirname($this->output_file)." check permissions!"; + return false; + } + } - /** - * in image mode this is done earlier, because we need already org_width and org_height - * to determine if image is cached or not - * in thumb mode this can only be done later, because there are also folders and videos - */ - if( ! $this->setSourceFileInformation() ) - { - return false; - } + /** + * use imagemagick or gdlib + */ + if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + include_once(LINPHA_DIR.'/lib/classes/image/linpha.imagemagick.class.php'); + + $this->imageTool = new LinImageMagick(); + $this->imageTool->imagemagickPath = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; + } + else + { + include_once(LINPHA_DIR.'/lib/classes/image/linpha.gdlib.class.php'); + + $this->imageTool = new LinGDLib(); + $this->imageTool->imgType = $this->img_type; + } - /** - * this results in fliped img_width and img_height for later photos_cache - * compare, we take care of it below... - */ - $array = $this->scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); - $this->img_width = $array['w']; - $this->img_height = $array['h']; + $this->imageTool->imgQuality = $this->img_quality; + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + } - /** - * check if entry in linpha_photos_cache exists - */ - /** - * Take care of fliped img_width and img_height, or it will result in a - * cache hit miss (scaleToFit() (above) takes the width and height from - * photos table, where values are wrong for images which need rotate) - */ - $rot = $GLOBALS['linpha']->db->GetRow("SELECT is_rotated, img_width, img_height " . + return true; + } + + /** + * set cached_id and output_file + * in image mode set also rotate, watermark, quality, ... + * and add an empty entry in the cache database + */ + function setCachedInfos() + { + if($this->mode == 'thumb') + { + $this->cached_id = $this->photo_id; + + $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id,$this->img_type); + } + elseif($this->mode == 'img') + { + /** + * check additional settings + */ + /** + * max_width and max_height + */ + if(isset($this->overrideSettings['max_width']) && isset($this->overrideSettings['max_height'])) + { + $this->max_width = $this->overrideSettings['max_width']; + $this->max_height = $this->overrideSettings['max_height']; + } + else + { + $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_width']; + $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_height']; + } + + /** + * update rotate (printing, ...) if applicable (no else() !! ) + * the rotate value from the database is read earlier + */ + if(isset($this->overrideSettings['rotate'])) + { + $this->rotate = $this->overrideSettings['rotate']; + } + + /** + * watermark (true|false) + */ + if(isset($this->overrideSettings['watermark'])) + { + $this->watermark = $this->overrideSettings['watermark']; + } + else + { + /** + * @todo place need_watermark() here + */ + $this->watermark = 0; + } + + /** + * quality + */ + if(isset($this->overrideSettings['quality'])) + { + $this->img_quality = intval($this->overrideSettings['quality']); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + } + else + { + $this->img_quality = intval($GLOBALS['linpha']->sql->config->value['sys_style_image_quality']); + } + + /** + * in image mode this is done earlier, because we need already org_width and org_height + * to determine if image is cached or not + * in thumb mode this can only be done later, because there are also folders and videos + */ + if( ! $this->setSourceFileInformation() ) + { + return false; + } + + /** + * this results in fliped img_width and img_height for later photos_cache + * compare, we take care of it below... + */ + $array = $this->scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); + $this->img_width = $array['w']; + $this->img_height = $array['h']; + + /** + * check if entry in linpha_photos_cache exists + */ + /** + * Take care of fliped img_width and img_height, or it will result in a + * cache hit miss (scaleToFit() (above) takes the width and height from + * photos table, where values are wrong for images which need rotate) + */ + $rot = $GLOBALS['linpha']->db->GetRow("SELECT is_rotated, img_width, img_height " . "FROM ".LIN_PREFIX."photos_cache " . "WHERE photo_id = '".$this->photo_id."' "); - if(isset($rot['is_rotated']) && $rot['is_rotated'] != 0) - { - - $dummy_height = $this->img_height; - $this->img_height = $this->img_width; - $this->img_width = $dummy_height; - linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Flipping width and height to get cache hit for image # ".$this->photo_id); - } - - $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . + if(isset($rot['is_rotated']) && $rot['is_rotated'] != 0) + { + + $dummy_height = $this->img_height; + $this->img_height = $this->img_width; + $this->img_width = $dummy_height; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Flipping width and height to get cache hit for image # ".$this->photo_id); + } + + $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE " . "photo_id = '".$this->photo_id."' AND " . "img_width = '".$this->img_width."' AND " . "img_height = '".$this->img_height."' AND " . @@ -259,411 +259,410 @@ "is_rotated = '".$this->rotate."' AND " . "has_watermark = '".$this->watermark."'"); - if(isset($data['id']) && !empty($data['id'])) - { - linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Cache HIT for image # ".$this->photo_id); + if(isset($data['id']) && !empty($data['id'])) + { + linLog(LOG_TYPE_IMPORT,LOG_INFO,'debug',"Cache HIT for image # ".$this->photo_id); - $this->cached_id = $data['id']; - $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); - } - else - { - linLog( LOG_TYPE_IMPORT,LOG_INFO,'image',"Cache MISS for image # ".$this->photo_id); - - - /** - * insert an empty entry and get cached_id - * we will update correct values only if create cached image has been successfull - */ - $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."photos_cache " . + $this->cached_id = $data['id']; + $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); + } + else + { + linLog( LOG_TYPE_IMPORT,LOG_INFO,'image',"Cache MISS for image # ".$this->photo_id); + + + /** + * insert an empty entry and get cached_id + * we will update correct values only if create cached image has been successfull + */ + $GLOBALS['linpha']->db->Execute("INSERT into ".LIN_PREFIX."photos_cache " . "(photo_id) VALUES ('".$this->photo_id."')"); - - $this->cached_id = $GLOBALS['linpha']->db->GetOne("SELECT MAX(id) " . + + $this->cached_id = $GLOBALS['linpha']->db->GetOne("SELECT MAX(id) " . "FROM ".LIN_PREFIX."photos_cache "); - $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); - - if(file_exists($this->output_file)) - { - /** - * o-oh, we're leaking old files in cache path, -> delete it - */ - unlink($this->output_file); - } - } - } + $this->output_file = LinImage::getCachePath('img',$this->cached_id,$this->img_type); + + if(file_exists($this->output_file)) + { + /** + * o-oh, we're leaking old files in cache path, -> delete it + */ + unlink($this->output_file); + } + } + } - -} -/** - * set source file informations - * - * @todo save values to database and read from there - */ -function setSourceFileInformation() -{ - if($this->img_type != 0 && $this->img_type != 9999999) - { - $this->src_file = LinSql::getFullImagePath( $this->photo_id ); + } - if(! file_exists($this->src_file)) - { - echo $this->src_file.' '; - echo i18n("File doesnt exist anymore").'. '; - echo i18n("You should consider start a re-import of your files/folders").'<br />'; - return false; - } - } - - return true; -} + /** + * set source file informations + * + * @todo save values to database and read from there + */ + function setSourceFileInformation() + { + if($this->img_type != 0 && $this->img_type != 9999999) + { + $this->src_file = LinSql::getFullImagePath( $this->photo_id ); + if(! file_exists($this->src_file)) + { + echo $this->src_file.' '; + echo i18n("File doesnt exist anymore").'. '; + echo i18n("You should consider start a re-import of your files/folders").'<br />'; + return false; + } + } -/** - * thumbnail functions - * - * @return true on success, false on failure (checks for valid id, valid image, valid permission!) - */ - function createThumbnail($photo_id) - { - $this->mode = 'thumb'; - $this->photo_id = $photo_id; + return true; + } - if( ! $this->setFileInformation() ) - { - return false; - } - - if( ! $this->isCached ) - { - if( ! $this->setSourceFileInformation() ) - { - return false; - } - - linLog(LOG_TYPE_IMPORT,LOG_INFO,'thumbnail',"Creating thumbnail ".$this->photo_id); + /** + * thumbnail functions + * + * @return true on success, false on failure (checks for valid id, valid image, valid permission!) + */ + function createThumbnail($photo_id) + { + $this->mode = 'thumb'; + $this->photo_id = $photo_id; - /** - * image thumbnail - */ - if( LinIdentify::isSupportedImage( $this->img_type ) ) - { - $this->createThumbnailImage(); - } - /** - * folder thumbnail - */ - elseif($this->img_type == 0) - { - if( ! $this->createThumbnailFolder() ) - { - $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; - } - } - /** - * video thumbnail - */ - elseif( LinIdentify::isVideo( $this->img_type ) ) - { - $this->createThumbnailVideo(); - } + if( ! $this->setFileInformation() ) + { + return false; + } - if( ! file_exists( $this->output_file ) ) - { - $this->error_msg = "Output File Doesnt Exists"; - return false; - } - } - - return true; - } - - function createThumbnailImage() - { - /** - * Exiftool can be used to extract the embedded thumbnail within the - * EXIF segment of the image. Most cameras support it. - * It is usually 5-10 times faster than using convert and is perfect - * when low on memory or with older CPU, even so the thumbs didn't look - * that nice as the ones created with convert ;-) - */ - if($GLOBALS['linpha']->sql->config->value['sys_import_use_emb_thumb']) + if( ! $this->isCached ) { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); - - $objExifTool = new LinExifTool; + if( ! $this->setSourceFileInformation() ) + { + return false; + } - /** - * Default fallback if image doesn't contain embedded thumb - */ - if(!$objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) - { - $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $this->imageTool->imgQuality = 75; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'thumbnail',"Creating thumbnail ".$this->photo_id); - $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); - } + /** + * image thumbnail + */ + if( LinIdentify::isSupportedImage( $this->img_type ) ) + { + $this->createThumbnailImage(); + } + /** + * folder thumbnail + */ + elseif($this->img_type == 0) + { + if( ! $this->createThumbnailFolder() ) + { + $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; + } + } + /** + * video thumbnail + */ + elseif( LinIdentify::isVideo( $this->img_type ) ) + { + $this->createThumbnailVideo(); + } + + if( ! file_exists( $this->output_file ) ) + { + $this->error_msg = "Output File Doesnt Exists"; + return false; + } } + + return true; + } + + function createThumbnailImage() + { + /** + * Exiftool can be used to extract the embedded thumbnail within the + * EXIF segment of the image. Most cameras support it. + * It is usually 5-10 times faster than using convert and is perfect + * when low on memory or with older CPU, even so the thumbs didn't look + * that nice as the ones created with convert ;-) + */ + if($GLOBALS['linpha']->sql->config->value['sys_import_use_emb_thumb']) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + + $objExifTool = new LinExifTool; + + /** + * Default fallback if image doesn't contain embedded thumb + */ + if(!$objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) + { + $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->imageTool->imgQuality = 75; + + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + } + } else { /** - * include the file which contains the imagemagick strings and exec() / gdlib instructions - */ + * include the file which contains the imagemagick strings and exec() / gdlib instructions + */ $this->imageTool->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; $this->imageTool->imgQuality = 75; $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); } - } - - function createThumbnailFolder() - { - /** - * check if we have already some thumbnails in this folder - * and create array_ids which holds 4 image ids - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->photo_id )."'"); - $array_thumbs = Array(); - $i=0; - while($data = $query->FetchRow()) - { - if($i >= 4) - { - break; - } - - $file = LinImage::getCachePath('thumb',$data['id'],$data['img_type']); + } - if( file_exists( $file ) ) - { - if($data['1']=='0') { // folders are gif files, all others are jpg - $type = '1'; - } else { - $type = '2'; - } + function createThumbnailFolder() + { + /** + * check if we have already some thumbnails in this folder + * and create array_ids which holds 4 image ids + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->photo_id )."'"); + $array_thumbs = Array(); + $i=0; + while($data = $query->FetchRow()) + { + if($i >= 4) + { + break; + } + + $file = LinImage::getCachePath('thumb',$data['id'],$data['img_type']); - $array_thumbs[] = array('id' => $data['id'],'file' => $file, 'type' => $type); - $i++; - } - } - - /** - * no images found in this folder - */ - if(count($array_thumbs) == 0) - { - return false; - } + if( file_exists( $file ) ) + { + if($data['1']=='0') { // folders are gif files, all others are jpg + $type = '1'; + } else { + $type = '2'; + } - $this->imageTool->createThumbnailFolder($this->output_file,$array_thumbs); - - if( !file_exists($this->output_file)) - { - return false; - } - else - { - return true; - } - } - - function createThumbnailVideo() - { - $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/video.jpg'; - $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $this->img_quality = 75; - //$this->imageTool->orgWidth = 320; - //$this->imageTool->orgHeight = 240; + $array_thumbs[] = array('id' => $data['id'],'file' => $file, 'type' => $type); + $i++; + } + } + + /** + * no images found in this folder + */ + if(count($array_thumbs) == 0) + { + return false; + } + + $this->imageTool->createThumbnailFolder($this->output_file,$array_thumbs); + + if( !file_exists($this->output_file)) + { + return false; + } + else + { + return true; + } + } + + function createThumbnailVideo() + { + $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/video.jpg'; + $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->img_quality = 75; + //$this->imageTool->orgWidth = 320; + //$this->imageTool->orgHeight = 240; $video_thumbnail_created = false; - - /** - * check if there exists a .thm file - * (video thumbnail of Canon videos) - */ - $pos = strrpos($this->src_file,'.'); - $start = substr($this->src_file,0,$pos); - $thm_file = $start.'.thm'; - - if(file_exists($thm_file)) - { - list($this->org_width, $this->org_height, $file_type) = - LinIdentify::linGetImageSize($thm_file); - + + /** + * check if there exists a .thm file + * (video thumbnail of Canon videos) + */ + $pos = strrpos($this->src_file,'.'); + $start = substr($this->src_file,0,$pos); + $thm_file = $start.'.thm'; + + if(file_exists($thm_file)) + { + list($this->org_width, $this->org_height, $file_type) = + LinIdentify::linGetImageSize($thm_file); + $this->src_file = $thm_file; - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - $this->imageTool->imgType = $file_type; - $this->imageTool->img_thumbsize = $this->img_thumbsize; - $this->imageTool->imgQuality = 75; - $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); - $video_thumbnail_created = true; - } - - if(!$video_thumbnail_created) - { - /** + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + $this->imageTool->imgType = $file_type; + $this->imageTool->img_thumbsize = $this->img_thumbsize; + $this->imageTool->imgQuality = 75; + $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); + $video_thumbnail_created = true; + } + + if(!$video_thumbnail_created) + { + /** * try getting thumbnail with exiftool if requested */ - if($GLOBALS['linpha']->sql->config->value['sys_im_video_thumbnail'] && - $GLOBALS['linpha']->sql->config->value['sys_import_exiftool_avail'] ) - { - include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); + if($GLOBALS['linpha']->sql->config->value['sys_im_video_thumbnail'] && + $GLOBALS['linpha']->sql->config->value['sys_import_exiftool_avail'] ) + { + include_once(LINPHA_DIR.'/lib/classes/linpha.exiftool.class.php'); $objExifTool = new LinExifTool(); if($objExifTool->getEmbeddedThumbnail($this->src_file, $this->output_file)) { /** * get width and height from thumb - - list($this->org_width, $this->org_height, $file_type) = - LinIdentify::linGetImageSize($this->src_file); - - $this->imageTool->orgWidth = $this->org_width; - $this->imageTool->orgHeight = $this->org_height; - */ - $video_thumbnail_created = true; + + list($this->org_width, $this->org_height, $file_type) = + LinIdentify::linGetImageSize($this->src_file); + + $this->imageTool->orgWidth = $this->org_width; + $this->imageTool->orgHeight = $this->org_height; + */ + $video_thumbnail_created = true; } else // try getting at least codec for imagemagick { - /** - * only if codec is mjpg, because otherwise we get an access - * violation message box on the servers desktop of convert.exe - * (already reported to imagemagick http://studio. imagemagick. - * org/magick/viewtopic.php?t=2868) - */ - $file_info = $objExifTool->readMetaDataFromFile("all", $this->src_file); - - if(isset($file_info['Codec']) && - $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) - { - $codec = strtolower($file_info['Codec']); - if(strpos($codec, "mjpeg") !== false - OR strpos($codec, "motion jpeg") !== false - OR strpos($codec, "motion jpg") !== false - OR strpos($codec, "mjpg") !== false) - { - $return_value = $this->imageTool->createThumbnailVideo($this->src_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize); - - if($return_value == 0 && file_exists($this->output_file)) /* && empty($array_output[0]) */ - { - $video_thumbnail_created = true; - } - else - { - $video_thumbnail_created = false; - } - } - } - else - { - $video_thumbnail_created = false; - } + /** + * only if codec is mjpg, because otherwise we get an access + * violation message box on the servers desktop of convert.exe + * (already reported to imagemagick http://studio. imagemagick. + * org/magick/viewtopic.php?t=2868) + */ + $file_info = $objExifTool->readMetaDataFromFile("all", $this->src_file); + + if(isset($file_info['Codec']) && + $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + $codec = strtolower($file_info['Codec']); + if(strpos($codec, "mjpeg") !== false + OR strpos($codec, "motion jpeg") !== false + OR strpos($codec, "motion jpg") !== false + OR strpos($codec, "mjpg") !== false) + { + $return_value = $this->imageTool->createThumbnailVideo($this->src_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize); + + if($return_value == 0 && file_exists($this->output_file)) /* && empty($array_output[0]) */ + { + $video_thumbnail_created = true; + } + else + { + $video_thumbnail_created = false; + } + } + } + else + { + $video_thumbnail_created = false; + } } - } - else - { - $video_thumbnail_created = false; - } - } - - /** - * copy the video icon in the lower right corner - */ - if($video_thumbnail_created) - { - /** - * watermark currently broken - image scaling wrong and distorted - * also - so disable temporary (flo?) - */ - /* - include_once(LINPHA_DIR.'/lib/plugins/watermark/func.watermark.php'); - $this->imageTool->wm_config = Array( - 'wm_watermark' => 2, - 'wm_align' => 'southeast', - 'wm_dissolve' => 100, - 'wm_img_img' => $dummy_thumbnail, - 'wm_resize' => 'no', // use 'no' because the gdlib cannot handle transparent images with imagecopyresized() !! - 'wm_horizontal' => 5, - 'wm_vertical' => 5 - ); - */ - /** - * warning: session will be closed! - */ - //$this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib - //$this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib + } + else + { + $video_thumbnail_created = false; + } + } - //$this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); - } - else - { - /** - * use default video icon - */ - $this->output_file = $dummy_thumbnail; - } - } + /** + * copy the video icon in the lower right corner + */ + if($video_thumbnail_created) + { + /** + * watermark currently broken - image scaling wrong and distorted + * also - so disable temporary (flo?) + */ + /* + include_once(LINPHA_DIR.'/lib/plugins/watermark/func.watermark.php'); + $this->imageTool->wm_config = Array( + 'wm_watermark' => 2, + 'wm_align' => 'southeast', + 'wm_dissolve' => 100, + 'wm_img_img' => $dummy_thumbnail, + 'wm_resize' => 'no', // use 'no' because the gdlib cannot handle transparent images with imagecopyresized() !! + 'wm_horizontal' => 5, + 'wm_vertical' => 5 + ); + */ + /** + * warning: session will be closed! + */ + //$this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); + } + else + { + /** + * use default video icon + */ + $this->output_file = $dummy_thumbnail; + } + } -/** - * image functions - */ - function createImage($photo_id, $overrideSettings) - { - $this->mode = 'img'; - $this->photo_id = $photo_id; - - $this->overrideSettings = $overrideSettings; - if( ! $this->setFileInformation() ) // will also do setCachedInfos() and setSourceFileInformation() - { - return false; - } - - if( ! $this->isCached OR $this->force ) - { - linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Creating image ".$this->photo_id); - - /** - * include the create image script - */ - linStartTimer("createimage"); - - $this->imageTool->createImage($this->src_file,$this->output_file,$this->img_width,$this->img_height,$this->rotate,$this->watermark); + /** + * image functions + */ + function createImage($photo_id, $overrideSettings) + { + $this->mode = 'img'; + $this->photo_id = $photo_id; - $time = linStopTimer("createimage") * 1000000; - - //echo $time; exit(); + $this->overrideSettings = $overrideSettings; - if( ! file_exists( $this->output_file ) ) - { - $this->error_msg = "Output File Doesnt Exists"; - return false; - } + if( ! $this->setFileInformation() ) // will also do setCachedInfos() and setSourceFileInformation() + { + return false; + } - /** - * finish cache entry - */ - $filesize = filesize( $this->output_file ); - if($filesize <= 0) - { - $this->error_msg = "Incorrect filesize (".$filesize.")"; - return false; - } + if( ! $this->isCached OR $this->force ) + { + linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Creating image ".$this->photo_id); + + /** + * include the create image script + */ + linStartTimer("createimage"); + + $this->imageTool->createImage($this->src_file,$this->output_file,$this->img_width,$this->img_height,$this->rotate,$this->watermark); - /** - * If image needs rotating (by EXIF value) flip width and height - * to have the right values in photos_cache - */ - if($this->rotate != 0) - { - $dummy_height = $this->img_height; - $this->img_height = $this->img_width; - $this->img_width = $dummy_height; - linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Height/width flip during storage of image # ".$this->photo_id." in photos_cache" ); - - } - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache SET " . + $time = linStopTimer("createimage") * 1000000; + + //echo $time; exit(); + + if( ! file_exists( $this->output_file ) ) + { + $this->error_msg = "Output File Doesnt Exists"; + return false; + } + + /** + * finish cache entry + */ + $filesize = filesize( $this->output_file ); + if($filesize <= 0) + { + $this->error_msg = "Incorrect filesize (".$filesize.")"; + return false; + } + + /** + * If image needs rotating (by EXIF value) flip width and height + * to have the right values in photos_cache + */ + if($this->rotate != 0) + { + $dummy_height = $this->img_height; + $this->img_height = $this->img_width; + $this->img_width = $dummy_height; + linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Height/width flip during storage of image # ".$this->photo_id." in photos_cache" ); + + } + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache SET " . "img_width = '".$this->img_width."', " . "img_height = '".$this->img_height."', " . "img_quality = '".$this->img_quality."', " . @@ -673,257 +672,255 @@ "time_add = '".time()."', " . "time_creating = '".$time."' " . "WHERE id = '".$this->cached_id."'"); - } - else - { - /** - * got a cached copy, increment counter and time_use - */ - $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache " . + } + else + { + /** + * got a cached copy, increment counter and time_use + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos_cache " . "SET hits = hits + 1, time_use = '".time()."' " . "WHERE id = '".$this->cached_id."'"); - } + } - return true; - } + return true; + } - -/** - * Rotates images when called from menu direction left/right. - * Insert rotation value into linpha_photos and flip image width - * and height in table. - * Later do a force recreate - * - * @param string $direction either 90 (right turn) or -90 (left turn) - * @param int $linID - * - */ - function rotateImageByMenuCall($direction, $linId) - { - /** - * Insert ration value in linpha_photos - */ - $rotate = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . + /** + * Rotates images when called from menu direction left/right. + * Insert rotation value into linpha_photos and flip image width + * and height in table. + * Later do a force recreate + * + * @param string $direction either 90 (right turn) or -90 (left turn) + * @param int $linID + * + */ + function rotateImageByMenuCall($direction, $linId) + { + /** + * Insert ration value in linpha_photos + */ + $rotate = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos " . "SET rotate='".LinSql::linAddslashes($direction)."' " . "WHERE id='".$linId."'"); - - /** - * Flip image width and height - */ - $imagedata = $GLOBALS['linpha']->db->GetRow("SELECT width AS width, height AS height " . + + /** + * Flip image width and height + */ + $imagedata = $GLOBALS['linpha']->db->GetRow("SELECT width AS width, height AS height " . "FROM ".LIN_PREFIX."photos " . "WHERE id='".LinSql::linAddslashes($linId)."' "); - - $flip = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos SET " . + + $flip = $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."photos SET " . "width = '".LinSql::linAddslashes($imagedata['height'])."', " . "height = '".LinSql::linAddslashes($imagedata['width'])."' " . "WHERE id='".LinSql::linAddslashes($linId)."'"); - - /** - * force recreate with new values - */ - $thumbnail = new LinImage(); - $_GET['force'] = true; - $thumbnail->createThumbnail( $linId ); - } + /** + * force recreate with new values + */ + $thumbnail = new LinImage(); + $_GET['force'] = true; + $thumbnail->createThumbnail( $linId ); + } -/** - * returns the full path to the cached image - * in thumb mode, $id is the photoid - * in image mode, $id is the cached photoid - * - * @param string $what 'thumb' or 'img' - * @param int $id image id - * @return string full path to cached image - * - * @todo use img_type as parameter and decide in this function - * which file extension to use - */ -function getCachePath($what,$id,$img_type) -{ - /** - * thumbnails of folders are gif files, all others are (currently at least) jpg files - */ - if($what == 'thumb' && $img_type == '0') { - $ext = 'gif'; - } else { - $ext = 'jpg'; - } - - $path = LinSql::getPath('cache'); - - if(strlen($id)==1) - { - $subdir = $id.'0'; // dont use foldernames 1-9 because it would only contain one image per folder - } - else - { - $subdir = substr($id,0,2); - } - - return $path . '/' . $what . '/' . $subdir . '/' . $id . '.' . $ext; -} + /** + * returns the full path to the cached image + * in thumb mode, $id is the photoid + * in image mode, $id is the cached photoid + * + * @param string $what 'thumb' or 'img' + * @param int $id image id + * @return string full path to cached image + * + * @todo use img_type as parameter and decide in this function + * which file extension to use + */ + function getCachePath($what,$id,$img_type) + { + /** + * thumbnails of folders are gif files, all others are (currently at least) jpg files + */ + if($what == 'thumb' && $img_type == '0') { + $ext = 'gif'; + } else { + $ext = 'jpg'; + } -/** - * deleteCached thumbnail by id - * - * @param int $id id of thumb in database - * @return boolean false if there was no image, true if there was an image to delete - */ -function deleteCachedThumbnail($id,$img_type) -{ - $output = LinImage::getCachePath('thumb',$id,$img_type); - - if(file_exists($output)) - { - if( ! @unlink( $output ) ) - { - linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); - } - - return true; - } - else - { - return false; - } -} + $path = LinSql::getPath('cache'); -/** - * delete all cached images by this photo id - * (there can be more than one image with the same photo id in different sizes etc.) - * - * @param int $id id of image in database - */ -function deleteCachedImage($id,$img_type) -{ - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE photo_id = '".$id."'"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) - { - $output = LinImage::getCachePath('img',$data[0],$img_type); - - if(file_exists($output)) - { - if( ! @unlink( $output ) ) - { - linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); - } - } - } -} + if(strlen($id)==1) + { + $subdir = $id.'0'; // dont use foldernames 1-9 because it would only contain one image per folder + } + else + { + $subdir = substr($id,0,2); + } -/** - * This returns returns width and height of the scaled image - * to fit in $dst_h and $dst_w, it keeps the image ratio - * calculated from $src_h and $src_w - * if $no_increase is set, the image is only decreased - */ -function scaleToFit($src_w,$src_h,$dst_w,$dst_h,$no_increase=1) -{ - if($src_h == 0 OR $src_w == 0) - { - return array('w' => 0, 'h' => 0); - } + return $path . '/' . $what . '/' . $subdir . '/' . $id . '.' . $ext; + } - $img_relation = $src_w/$src_h; + /** + * deleteCached thumbnail by id + * + * @param int $id id of thumb in database + * @return boolean false if there was no image, true if there was an image to delete + */ + function deleteCachedThumbnail($id,$img_type) + { + $output = LinImage::getCachePath('thumb',$id,$img_type); - // Image is smaller than screen, no resize required - if (($src_w <= $dst_w) && ($src_h <= $dst_h) && $no_increase) - { - $array['w'] = $src_w; - $array['h'] = $src_h; - } - else - { - /* - The image is way bigger than the screen, resize maintaining aspect ratio + if(file_exists($output)) + { + if( ! @unlink( $output ) ) + { + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); + } - $src_w, $src_h: original image sizes - $dst_w, $dst_h: screen width and height - $img_relation = $src_w/$src_h; - - Either $dst_w decisive or $dst_h, usually $dst_h - */ + return true; + } + else + { + return false; + } + } - $tmp_height = $dst_w / $img_relation; // calc the new height with screen width - if ($tmp_height > $dst_h) { // we were wrong, it's still widther than screen -> $dst_h is decisive - $array['w'] = round($img_relation*$dst_h); - $array['h'] = intval($dst_h); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - } else { - $array['w'] = intval($dst_w); // oh, do intval() for security, comes from $_GET and will be included in exec() commands - $array['h'] = round($tmp_height); - } - } - - return $array; -} + /** + * delete all cached images by this photo id + * (there can be more than one image with the same photo id in different sizes etc.) + * + * @param int $id id of image in database + */ + function deleteCachedImage($id,$img_type) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".LIN_PREFIX."photos_cache WHERE photo_id = '".$id."'"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $output = LinImage::getCachePath('img',$data[0],$img_type); -/** - * send correct header and file - */ -function printFileToScreen() -{ - if( $this->img_type == 0 ) // folder are gif images, all other are jpg - { - header("Content-type: image/gif"); - } - else - { - header("Content-type: image/jpeg"); - } - - /** - * show correct image filename wenn selecting "save as" in browser - * it works on firefox, but it does not on my IE - */ - header("Content-Disposition: inline; filename=".basename($this->src_file).";" ); - - readfile( $this->output_file ); -} + if(file_exists($output)) + { + if( ! @unlink( $output ) ) + { + linSysLog( i18n("Warning while deleting file/folder, check permissions!").'<br />'.$output ); + } + } + } + } -/** - * rotates an image with a given angle using GDLib - * do nothing if imagerotate() doesn't exists - * - * - * @param imageressource $src_img pointer to the source image - * @param int $angle angle to rotate - * @author flo - */ -function GDimageRotate(& $src_img, $angle) -{ - if($angle != "0") - { - if(function_exists('imagerotate')) - { - /** - * flip $angle, because with this function, left means right, and right means left :-) - */ - $angle = 360 - $angle; - $angle = $angle % 360; - $src_img = imagerotate($src_img,$angle,0); - } - else - { - linLog(LOG_TYPE_META,LOG_WARNING,'rotate',"Cannot rotate image becuase the function imagerotate() doesnt exists, consider upgrading your php version"); - } - } -} + /** + * This returns returns width and height of the scaled image + * to fit in $dst_h and $dst_w, it keeps the image ratio + * calculated from $src_h and $src_w + * if $no_increase is set, the image is only decreased + */ + function scaleToFit($src_w,$src_h,$dst_w,$dst_h,$no_increase=1) + { + if($src_h == 0 OR $src_w == 0) + { + return array('w' => 0, 'h' => 0); + } -function &GDimageCreateFrom($src_file,$img_type) -{ - switch($img_type) - { - case 1: $src_image = imagecreatefromgif($src_file); break; - case 2: $src_image = imagecreatefromjpeg($src_file); break; - case 3: $src_image = imagecreatefrompng($src_file); break; - default: $foobar = false; return $foobar; break; - } - - return $src_image; -} - + $img_relation = $src_w/$src_h; + + // Image is smaller than screen, no resize required + if (($src_w <= $dst_w) && ($src_h <= $dst_h) && $no_increase) + { + $array['w'] = $src_w; + $array['h'] = $src_h; + } + else + { + /* + The image is way bigger than the screen, resize maintaining aspect ratio + + $src_w, $src_h: original image sizes + $dst_w, $dst_h: screen width and height + $img_relation = $src_w/$src_h; + + Either $dst_w decisive or $dst_h, usually $dst_h + */ + + $tmp_height = $dst_w / $img_relation; // calc the new height with screen width + if ($tmp_height > $dst_h) { // we were wrong, it's still widther than screen -> $dst_h is decisive + $array['w'] = round($img_relation*$dst_h); + $array['h'] = intval($dst_h); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + } else { + $array['w'] = intval($dst_w); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + $array['h'] = round($tmp_height); + } + } + + return $array; + } + + /** + * send correct header and file + */ + function printFileToScreen() + { + if( $this->img_type == 0 ) // folder are gif images, all other are jpg + { + header("Content-type: image/gif"); + } + else + { + header("Content-type: image/jpeg"); + } + + /** + * show correct image filename wenn selecting "save as" in browser + * it works on firefox, but it does not on my IE + */ + header("Content-Disposition: inline; filename=".basename($this->src_file).";" ); + + readfile( $this->output_file ); + } + + /** + * rotates an image with a given angle using GDLib + * do nothing if imagerotate() doesn't exists + * + * + * @param imageressource $src_img pointer to the source image + * @param int $angle angle to rotate + * @author flo + */ + function GDimageRotate(& $src_img, $angle) + { + if($angle != "0") + { + if(function_exists('imagerotate')) + { + /** + * flip $angle, because with this function, left means right, and right means left :-) + */ + $angle = 360 - $angle; + $angle = $angle % 360; + $src_img = imagerotate($src_img,$angle,0); + } + else + { + linLog(LOG_TYPE_META,LOG_WARNING,'rotate',"Cannot rotate image becuase the function imagerotate() doesnt exists, consider upgrading your php version"); + } + } + } + + function &GDimageCreateFrom($src_file,$img_type) + { + switch($img_type) + { + case 1: $src_image = imagecreatefromgif($src_file); break; + case 2: $src_image = imagecreatefromjpeg($src_file); break; + case 3: $src_image = imagecreatefrompng($src_file); break; + default: $foobar = false; return $foobar; break; + } + + return $src_image; + } + } // end class linImage ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2008-01-30 21:08:44 UTC (rev 4841) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2008-01-31 12:27:25 UTC (rev 4842) @@ -53,7 +53,6 @@ } - /** * set current view and set fileinfos of $GLOBALS['linpha']->template->idCurrent ($_GET['linId']) * @param string $modulname (album, browse, search, ...) @@ -152,7 +151,6 @@ } } - /** * main function to prepare desired layout view */ @@ -236,7 +234,6 @@ include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/global.html.php'); } - /** * filter out files and folders not permitted and escape filename * all other values dont have to be escaped @@ -268,7 +265,6 @@ unset($this->photos); } - /** * create optional top menu */ @@ -545,7 +541,6 @@ } } - /** * method for special admin commands, like rotating images, import stuff etc. * @uses LinImgview::buildImgView() @@ -613,9 +608,6 @@ } } - - - /** * define thumbnail view */ @@ -721,7 +713,6 @@ } } - /** * thumbnail view with javascript disabled (static) * @uses LinImgView::viewThumb() @@ -893,11 +884,6 @@ $GLOBALS['linpha']->template->setModuleName('view_thumbdetail'); } - - - - - /** * setup main/home view layout */ @@ -1062,10 +1048,6 @@ } } - - - - /** * setup basket view */ @@ -1150,9 +1132,6 @@ LinMetaData::saveModifiedMetaData(); } - - - /** * setup image view */ @@ -1306,7 +1285,7 @@ } /** - * store image informations in database if not exists + * store image informations in database if s */ function viewImgStoreImageInformation() { @@ -1325,6 +1304,21 @@ { $MetaData->saveData($value, $this->src_file, $this->md5sum ); } + + /** + * Read image geodata. This depends on the maps plugin. So we only + * run this additionally import if maps plugin is enabled and admin + * selected "autoimport". + * This should prevent a... [truncated message content] |