[Linpha-cvs] SF.net SVN: linpha: [4491] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-08 21:58:14
|
Revision: 4491 Author: fangehrn Date: 2006-04-08 14:57:45 -0700 (Sat, 08 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4491&view=rev Log Message: ----------- * startet writing linpha image class Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/get_image.php trunk/linpha2/get_thumb.php trunk/linpha2/index.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step11_finish.php trunk/linpha2/lib/classes/linpha.identify.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.sql.class.php trunk/linpha2/reset_database.php trunk/linpha2/templates/default/css/view_img.css Added Paths: ----------- trunk/linpha2/lib/include/image.gdlib.thumbnail.php trunk/linpha2/lib/include/image.imagemagick.thumbnail.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/ChangeLog 2006-04-08 21:57:45 UTC (rev 4491) @@ -8,6 +8,7 @@ - admin section * implemented home site configuration * implemented sort orders + * startet writing linpha image class 2006-04-07 flo * implemented admin section for user, groups and group memberships Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/get_image.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -0,0 +1,73 @@ +<?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. +*/ + +/** + * Image view + * @package Image + */ + +if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } + +include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); +$linpha = new linpha(); +$linpha->sql->startSession(); + +/** + * check for valid id + */ +try +{ + if(!isset( $_GET['id'] ) ) + { + throw new Exception("no id supplied!"); + } + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $_GET['id'] )."'"); + + if($query->RecordCount() != 1) + { + throw new Exception("wrong id supplied!"); + } + + $data = $query->FetchRow(); + + if( ! LinSql::photoIsAllowed( $data['id'] ) ) + { + throw new Exception("not permitted!"); + } + + if( isset($_GET['force'] ) ) { + $force = true; + } else { + $force = false; + } + + $output_file = LinImage::createImage($data['id'],$data['img_type'],$force); + if(file_exists($output_file)) + { + Header("Content-type: image/jpeg"); + readfile( $output_file ); + } +} +catch(Exception $error) +{ + echo "Error: ".$error -> getMessage(); +} + +?> \ No newline at end of file Modified: trunk/linpha2/get_thumb.php =================================================================== --- trunk/linpha2/get_thumb.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/get_thumb.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -45,7 +45,7 @@ throw new Exception("wrong id supplied!"); } - $data = $query->FetchRow(ADODB_FETCH_ASSOC); + $data = $query->FetchRow(); if( ! LinSql::photoIsAllowed( $data['id'] ) ) { @@ -58,12 +58,13 @@ $force = false; } - $output_file = LinImage::createThumbnail($data['id'],$data['img_type'],$force); - if(file_exists($output_file)) + $thumbnail = new LinImage(); + if( ! $thumbnail->createFile('thumb',$data['id'],$data['img_type'],$force) ) { - Header("Content-type: image/jpeg"); - readfile( $output_file ); + throw new Exception("Error while creating thumbnail!"); } + + $thumbnail->printFileToScreen(); } catch(Exception $error) { Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/index.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -7,7 +7,7 @@ * some init stuff */ include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); - $linpha = new linpha(); + $linpha = new Linpha(); $linpha->sql->startSession(); include_once(LINPHA_DIR.'/lib/include/integrity.php'); Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -28,8 +28,8 @@ $options = array( 'sys_db_version' => '2', 'sys_im_bracket_support' => $_SESSION['sys_im_bracket_support'], - 'sys_im_convert_path' => $_SESSION['sys_im_convert_path'], - 'sys_im_use_convert' => $_SESSION['sys_im_use_convert'], + 'sys_im_imagemagick_path' => $_SESSION['sys_im_convert_path'], + 'sys_im_use_imagemagick' => $_SESSION['sys_im_use_convert'], 'sys_im_video_thumbnail' => '1', 'sys_import_autoimport' => '1', 'sys_image_exif' => '1', @@ -39,7 +39,8 @@ 'sys_path_album_dir' => $_SESSION['album_dir'], 'sys_path_cache_dir' => $_SESSION['cache_dir'], 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], - 'sys_style_img_quality' => '75', + 'sys_style_image_quality' => '75', + 'sys_style_image_size' => '700', 'sys_style_home_showbrowsebydate' => '1', 'sys_style_home_nrrandomimages' => '4', 'sys_style_home_showalbums' => '1', @@ -47,7 +48,8 @@ 'sys_style_home_firstsortorder' => 'nameasc', 'sys_style_sortorder' => 'nameasc', 'sys_style_template' => 'default', - 'sys_style_tn_size' => '150', + 'sys_style_thumb_size_max' => '200', + 'sys_style_thumb_size_display' => '150', 'sys_user_autologin' => '1' ); Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/install/step10_postsettings.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -82,7 +82,7 @@ <?php $query = $linpha->db->Execute("SELECT option_value FROM ".PREFIX."config " . - "WHERE option_name='sys_im_use_convert'"); + "WHERE option_name='sys_im_use_imagemagick'"); $data = $query->FetchRow(); if(false === $data[0]) Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/install/step11_finish.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -82,7 +82,7 @@ { $result = $linpha->db->Execute("UPDATE ".PREFIX."config " . "SET option_value = '".LinSql::linAddslashes($_POST['sys_style_tn_size'])."' " . - "WHERE option_name = 'sys_style_tn_size'"); + "WHERE option_name = 'sys_style_thumb_size_max'"); if(!$result) { echo failed_msg(); Modified: trunk/linpha2/lib/classes/linpha.identify.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.identify.class.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/lib/classes/linpha.identify.class.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -64,7 +64,7 @@ */ function isSupportedImage($org_type) { - if( $GLOBALS['linpha']->sql->config->value['sys_im_use_convert'] ) { + if( $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick'] ) { if($org_type >= 1 && $org_type < 1000) { return true; } else { @@ -137,8 +137,8 @@ } else { - $identify_path = $GLOBALS['linpha']->sql->config->value['sys_im_convert_path'] ."identify"; - if( $GLOBALS['linpha']->sql->config->value['sys_im_use_convert'] ) + $identify_path = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path'] ."identify"; + if( $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick'] ) { /** * $array_output[0] contains something like '2272 1704 JPEG' Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -22,237 +22,323 @@ * This class provides a couple methods for image manipulation/creation * @package Image */ + +if(!defined('LINPHA_DIR')) { exit(1); } class LinImage { + +private $id; +private $img_type; +private $mode; + +private $output_file; +private $src_file, $org_width, $org_height; + /** - * delete thumbnail by id - * - * @param int $id id of thumb in database + * constructor */ -function deleteThumbnail($id) +function __construct() { - $output = linSql::getCachePath('thumb',$id); - - if(file_exists($output)) - { - unlink($output); - } } - -/** - * create thumbnail - * - * @param int $id thumbnail id - * @param int $img_type description - * @param bool $force force recreate of thumbs - */ -function createThumbnail($id,$img_type,$force) +function setFileInformation() { /** - * check if thumbnail already exists OR if forced + * check if already exists OR if forced */ - $output = linSql::getCachePath('thumb',$id); - if( ! file_exists( $output ) OR $force ) + $this->output_file = LinImage::getCachePath($this->mode,$this->id); + if( file_exists( $this->output_file ) AND !$this->force ) { - linSysLog("Create thumbnail".$id."<br />"); + $this->isCached = true; + } + else // !file_exists() OR $this->force + { + $this->isCached = false; /** * create subfolder if needed */ - if( ! file_exists( dirname($output) ) ) + if( ! file_exists( dirname($this->output_file) ) ) { - if( ! @mkdir( dirname($output) ) ) + if( ! @mkdir( dirname($this->output_file) ) ) { - echo "Cannot create folder ".dirname($output)." check permissions!"; + echo "Cannot create folder ".dirname($this->output_file)." check permissions!"; + return false; } } + } + + /** + * use imagemagick or gdlib + */ + if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + $this->include_str = 'imagemagick'; + } + else + { + $this->include_str = 'gdlib'; + } + + return true; +} + +function setSourceFileInformation() +{ + /** + * set source file informations + */ + if($this->img_type != 0 && $this->img_type != 9999999) + { + $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->id ); + $album_dir = $GLOBALS['linpha']->sql->getPath('album'); + $this->src_file = $album_dir .'/'. implode('/',$array_path); + + 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; + } + + list($this->org_width,$this->org_height,$org_type) = LinIdentify::linGetImageSize( $this->src_file ); + } + + return true; +} + +function printFileToScreen() +{ + if(file_exists($this->output_file)) + { + Header("Content-type: image/jpeg"); + readfile( $this->output_file ); + } +} + +function createFile($mode,$id,$img_type,$force) +{ + $this->id = $id; + $this->mode = $mode; + $this->force = $force; + $this->img_type = $img_type; + + if( ! $this->setFileInformation() ) + { + return false; + } + + if( ! $this->isCached) + { + if( ! $this->setSourceFileInformation() ) + { + return false; + } + + if($this->mode == 'thumb') + { + $this->createThumbnail(); + } + elseif($this->mode == 'image') + { + $this->createImage(); + } + } + + if( ! file_exists( $this->output_file ) ) + { + return false; + } + + return true; +} + + +/** + * thumbnail functions + */ + function createThumbnail() + { /** * create folder thumbnail */ - if($img_type == 0) + if($this->img_type == 0) { - /** - * check if we have already some thumbnails in this folder - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE parent_id = '".linSql::linAddslashes( $id )."'"); - $array_ids = Array(); - $i=0; - while($data = $query->FetchRow()) + if( ! $this->createThumbnailFolder() ) { - if($i >= 4) - { - break; - } - - if( file_exists( linSql::getCachePath('thumb',$data['id']) ) ) - { - $array_ids[] = $data['id']; - $i++; - } + $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; } + } + elseif( linIdentify::isVideo( $this->img_type ) ) + { + $this->createThumbnailVideo(); + } + elseif( linIdentify::isSupportedImage( $this->img_type ) ) + { + + $this->createThumbnailImage(); + } + } - if(count($array_ids)>=1) - { - /** - * create new tmp folder - */ - for($i=0; file_exists(LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i); $i++) { } - $tmp_folder = LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i; - mkdir($tmp_folder,0700); + function createThumbnailImage() + { + /** + * include the file which contains the imagemagick strings and exec() + */ + $thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $q = 75; + $img_type = $this->img_type; + $input = $this->src_file; + $output = $this->output_file; + $org_height = $this->org_height; + $org_width = $this->org_width; + + include(LINPHA_DIR.'/lib/include/image.'.$this->include_str.'.thumbnail.php'); + } - /** - * run imagemagick - */ - for($i=1; list($key,$value) = each($array_ids) ; $i++) - { - exec( "convert ". linSql::getCachePath('thumb',$value) . " -resize 80x80 ".$tmp_folder."/".$i.".jpg" ); - } + function createThumbnailFolder() + { + /** + * thumbnail icon only available with imagemagick + */ + if(! $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) + { + return false; + } - exec("convert -size 180x180 xc:lemonchiffon -mattecolor peru -frame 9x9+3+3 ".$output); - - for($i=1; $i<=count($array_ids); $i++ ) - { - switch($i) - { - case 1: - exec("composite -geometry +10+10 ".$tmp_folder."/1.jpg ".$output." ".$output); - break; - case 2: - exec("composite -geometry +100+10 ".$tmp_folder."/2.jpg ".$output." ".$output); - break; - case 3: - exec("composite -geometry +10+100 ".$tmp_folder."/3.jpg ".$output." ".$output); - break; - case 4: - exec("composite -geometry +100+100 ".$tmp_folder."/4.jpg ".$output." ".$output); - break; - } - } - - /** - * delete tmp folder - */ - reset($array_ids); - for($i=1; list($key,$value) = each($array_ids) ; $i++) - { - unlink( $tmp_folder .'/'. $i . '.jpg' ); - } - rmdir($tmp_folder); + /** + * check if we have already some thumbnails in this folder + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->id )."'"); + $array_ids = Array(); + $i=0; + while($data = $query->FetchRow()) + { + if($i >= 4) + { + break; } - else + + if( file_exists( LinImage::getCachePath('thumb',$data['id']) ) ) { - $output = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; + $array_ids[] = $data['id']; + $i++; } } - else // create image/video thumbnail + + if(count($array_ids) == 0) { - /** - * set source and output file - */ - $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $id ); - $album_dir = $GLOBALS['linpha']->sql->getPath('album'); - $src_file = $album_dir .'/'. implode('/',$array_path); - - if(! file_exists($src_file)) + return false; + } + + /** + * create new tmp folder + */ + for($i=0; file_exists(LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i); $i++) { } + $tmp_folder = LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i; + mkdir($tmp_folder,0700); + + /** + * run imagemagick + */ + for($i=1; list($key,$value) = each($array_ids) ; $i++) { - echo $src_file.' '; - echo i18n("File doesnt exist anymore").'. '; - echo i18n("You should consider start a re-import of your files/folders").'<br />'; + exec("convert ". LinImage::getCachePath('thumb',$value) . " -resize 80x80 ".$tmp_folder."/".$i.".jpg" ); } - else + + exec("convert -size 180x180 xc:lemonchiffon -mattecolor peru -frame 9x9+3+3 ".$this->output_file); + + for($i=1; $i<=count($array_ids); $i++ ) { - list($org_width,$org_height,$org_type) = LinIdentify::linGetImageSize( $src_file ); - - /** - * create video thumbnail - * @todo - */ - if( linIdentify::isVideo( $org_type ) ) + switch($i) { - /** - * @todo $tmp_file = create_video_thumbnail($src_file); - */ - $output = LINPHA_DIR.'/lib/graphics/avi_mov.gif'; - + case 1: + exec("composite -geometry +10+10 ".$tmp_folder."/1.jpg ".$this->output_file." ".$this->output_file); + break; + case 2: + exec("composite -geometry +100+10 ".$tmp_folder."/2.jpg ".$this->output_file." ".$this->output_file); + break; + case 3: + exec("composite -geometry +10+100 ".$tmp_folder."/3.jpg ".$this->output_file." ".$this->output_file); + break; + case 4: + exec("composite -geometry +100+100 ".$tmp_folder."/4.jpg ".$this->output_file." ".$this->output_file); + break; } - /** - * create image thumbnail - */ - elseif( linIdentify::isSupportedImage( $org_type ) ) - { - /** - * read thumbsize - */ - $thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_tn_size']; - $q = 75; - - - /*$max_width = $thumbsize; - $max_height = $thumbsize; - $w = $thumbsize; - $h = $thumbsize;*/ + } - /** - * set parameters - */ - /*$array = linImage::scaleToFit($org_height,$org_width,$max_height,$max_width,0); - $w = $array['w']; - $h = $array['h'];*/ - - - /** - * crop image - */ - $ratio = $org_width/$org_height; - if($ratio==1) - { - $x = 0; - $y = 0; - $w = $thumbsize; - $h = $thumbsize; - } - elseif($ratio>1) - { - $x = ( ($thumbsize*$ratio) - $thumbsize )/2; - $y = 0; - $w = ''; - $h = $thumbsize; - } - elseif($ratio<1) - { - $y = ( $thumbsize - ($thumbsize*$ratio) )/2; - $x = 0; - $w = $thumbsize; - $h = ''; - } - - $convert_str = 'convert'. - ' -quality '.$q. - ' -size '.$w.'x'.$h. // new size - ' -crop '.$thumbsize.'x'.$thumbsize.'+'.$x.'+'.$y. // crop - ' '.lin_escape_string( $src_file ).'[0]'. // [0] -> take only first frame!!! - ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles - ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images - ' '.lin_escape_string( $output ); - - exec( $convert_str ); - } + /** + * delete tmp folder + */ + reset($array_ids); + for($i=1; list($key,$value) = each($array_ids) ; $i++) + { + unlink( $tmp_folder .'/'. $i . '.jpg' ); } - } + rmdir($tmp_folder); } - if( ! file_exists( $output) ) + function createThumbnailVideo() { - echo "Thumbnail couldnt be created or opened!"; + /** + * @todo + */ + $this->output_file = LINPHA_DIR.'/lib/graphics/avi_mov.gif'; } + + +/** + * image functions + */ + function createImage() + { + + } + + + +/** + * returns the full path to the cached image + * in thumb mode, $id is the photoid + * in image mode, $id is the cached photoid + */ +function getCachePath($what,$id) +{ + $path = LinSql::getPath('cache'); - return $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); + } + + return $path .'/'. $what .'/' .$subdir .'/'.$id .'.jpg'; } +/** + * delete thumbnail by id + * + * @param int $id id of thumb in database + */ +function deleteThumbnail($id) +{ + $output = LinImage::getCachePath('thumb',$id); + + if(file_exists($output)) + { + if( ! @unlink( $output ) ) + { + linSysLog('Warning: '.$output.' cannot be deleted, check permissions'); + } + } +} /** * This returns returns width and height of the scaled image Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -1069,11 +1069,10 @@ /** - * set current thumb and image + * set current image and thumb */ - $GLOBALS['linpha']->template->output['image'] = '<img id="mainimage" src="'.LINPHA_DIR.'/get_thumb.php?id=' - . $this->photos_filtered[$this->current_key]['id'] . '" />' - . '<br />'.$this->photos_filtered[$this->current_key]['name']; + $GLOBALS['linpha']->template->output['image'] = '<img id="mainimage" src="'.LINPHA_DIR.'/get_image.php?id=' + . $this->photos_filtered[$this->current_key]['id'] . '" />'; $GLOBALS['linpha']->template->output['current_thumb'] = $this->viewImg_viewThumbHtml( $this->current_key , 'current' ); } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -217,14 +217,7 @@ /** * delete thumbnail in cache folder */ - $thumbnail = linSql::getCachePath('thumb',$photo_id); - if( file_exists( $thumbnail ) ) - { - if( ! @unlink( $thumbnail ) ) - { - linSysLog('Warning: '.$thumbnail.' cannot be deleted, check permissions'); - } - } + LinImage::deleteThumbnail($photo_id); } /** Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -553,22 +553,6 @@ return LinFilesys::getFullPath( $path ); } -function getCachePath($what,$id) -{ - $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 .'.jpg'; -} - /** * Set autologin-cookie * Added: trunk/linpha2/lib/include/image.gdlib.thumbnail.php =================================================================== --- trunk/linpha2/lib/include/image.gdlib.thumbnail.php (rev 0) +++ trunk/linpha2/lib/include/image.gdlib.thumbnail.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -0,0 +1,96 @@ +<?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. +*/ + +/** + * Create thumbnails with gdlib + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * calculate crop + */ + $ratio = $org_width/$org_height; + if($ratio==1) + { + $x = 0; + $y = 0; + $w = $thumbsize; + $h = $thumbsize; + } + elseif($ratio>1) + { + $x = ( $org_width - $org_height )/2; + $y = 0; + $w = $thumbsize; + $h = $thumbsize; + $src_size = $org_height; + } + elseif($ratio<1) + { + $y = ( $org_height - $org_width )/2; + $x = 0; + $w = $thumbsize; + $h = $thumbsize; + + $src_size = $org_width; + } + + +/** + * create image resources + */ + switch($img_type) + { + case 1: $src_image = imagecreatefromgif($input); break; + case 2: $src_image = imagecreatefromjpeg($input); break; + case 3: $src_image = imagecreatefrompng($input); break; + default: return false;; + } + $scaled_image = imagecreatetruecolor($thumbsize, $thumbsize); + +/** + * resize and crop image + */ + imagecopyresized( + $scaled_image,$src_image, + 0,0, // int dstX, int dstY + $x,$y, // int srcX, int srcY + $w,$h, // int dstW, int dstH + $src_size,$src_size // int srcW, int srcH + ); + +/** + * destroy source image + */ + imagedestroy($src_image); + +/** + * save image + */ + imagejpeg($scaled_image,$output,$q); + +/** + * destroy scaled image + */ + imagedestroy($scaled_image); + +?> \ No newline at end of file Added: trunk/linpha2/lib/include/image.imagemagick.thumbnail.php =================================================================== --- trunk/linpha2/lib/include/image.imagemagick.thumbnail.php (rev 0) +++ trunk/linpha2/lib/include/image.imagemagick.thumbnail.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -0,0 +1,68 @@ +<?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. +*/ + +/** + * Create thumbnails with imagemagick + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * crop image + */ +$ratio = $org_width/$org_height; +if($ratio==1) +{ + $x = 0; + $y = 0; + $w = $thumbsize; + $h = $thumbsize; +} +elseif($ratio>1) +{ + $x = ( ($thumbsize*$ratio) - $thumbsize )/2; + $y = 0; + $w = ''; + $h = $thumbsize; +} +elseif($ratio<1) +{ + $y = ( $thumbsize - ($thumbsize*$ratio) )/2; + $x = 0; + $w = $thumbsize; + $h = ''; +} + +$q = 100; + + +$convert_str = 'convert'. + ' -quality '.$q. + ' -size '.$w.'x'.$h. // new size + ' -crop '.$thumbsize.'x'.$thumbsize.'+'.$x.'+'.$y. // crop + ' '.lin_escape_string( $input ).'[0]'. // [0] -> take only first frame!!! + ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles + ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images + ' '.lin_escape_string( $output ); + +exec( $convert_str ); + +?> \ No newline at end of file Modified: trunk/linpha2/reset_database.php =================================================================== --- trunk/linpha2/reset_database.php 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/reset_database.php 2006-04-08 21:57:45 UTC (rev 4491) @@ -7,8 +7,8 @@ $_SESSION['sys_im_bracket_support'] = $GLOBALS['linpha']->sql->config->value['sys_im_bracket_support']; -$_SESSION['sys_im_use_convert'] = $GLOBALS['linpha']->sql->config->value['sys_im_use_convert']; -$_SESSION['sys_im_convert_path'] = $GLOBALS['linpha']->sql->config->value['sys_im_convert_path']; +$_SESSION['sys_im_use_convert'] = $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']; +$_SESSION['sys_im_convert_path'] = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; $_SESSION['language'] = $GLOBALS['linpha']->sql->config->value['sys_lang']; $_SESSION['album_dir'] = $GLOBALS['linpha']->sql->config->value['sys_path_album_dir']; $_SESSION['cache_dir'] = $GLOBALS['linpha']->sql->config->value['sys_path_cache_dir']; Modified: trunk/linpha2/templates/default/css/view_img.css =================================================================== --- trunk/linpha2/templates/default/css/view_img.css 2006-04-08 19:38:58 UTC (rev 4490) +++ trunk/linpha2/templates/default/css/view_img.css 2006-04-08 21:57:45 UTC (rev 4491) @@ -10,8 +10,6 @@ } #mainimage { - width: 350px; - height: auto; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |