|
From: FlorinCB <ory...@us...> - 2009-01-08 20:44:20
|
Update of /cvsroot/mxbb/mx_smartor/album_mod/modules In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv16644/album_mod/modules Modified Files: album_picm.php Log Message: Version 2.9.7 - album mid pic fixed to resize GIF files on the fly ;) Index: album_picm.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/modules/album_picm.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** album_picm.php 4 Sep 2008 20:36:18 -0000 1.4 --- album_picm.php 8 Jan 2009 20:43:41 -0000 1.5 *************** *** 121,125 **** $album_user_access = album_user_access($cat_id, $thiscat, 1, 0, 1, 1, 1, 1); ! if (($auth_data['view'] == 0) && ($album_user_access['view'] == false)) { mx_message_die(GENERAL_MESSAGE, $lang['Not_Authorised']); --- 121,125 ---- $album_user_access = album_user_access($cat_id, $thiscat, 1, 0, 1, 1, 1, 1); ! if (($album_user_access['view'] == 0) && ($album_user_access['view'] == false)) { mx_message_die(GENERAL_MESSAGE, $lang['Not_Authorised']); *************** *** 185,189 **** */ - // ------------------------------------ // Send Thumbnail to browser --- 185,188 ---- *************** *** 195,198 **** --- 194,274 ---- // GD does not support GIF so we must SEND a premade No-thumbnail pic then EXIT // -------------------------------- + + + if ($pic_thumbnail) + { + $thumbnail_size = 500; + $thumbnail_width = ($album_sp_config['midthumb_width']) ? $album_sp_config['midthumb_width'] : 350; + $thumbnail_height = ($album_sp_config['midthumb_height']) ? $album_sp_config['midthumb_height'] : 350; + + switch ($pic_filetype) + { + case '.gif': + $file_header = 'Content-type: image/gif'; + $read_function = 'imagecreatefromgif'; + break; + case '.jpeg': + case '.jpg': + case '.pjpeg': + $file_header = 'Content-type: image/jpeg'; + $read_function = 'imagecreatefromjpeg'; + break; + case '.png': + $file_header = 'Content-type: image/png'; + $read_function = 'imagecreatefrompng'; + break; + default: + header('Content-type: image/jpeg'); + $file_header = 'Content-type: image/jpeg'; + $read_function = 'imagecreatefromjpeg'; + } + + header($file_header); + + $pic_size = @getimagesize($pic_fullpath); + $pic_width = $pic_size[0]; + $pic_height = $pic_size[1]; + + + if ($pic_width > $pic_height) + { + $thumbnail_width = $thumbnail_size; + $thumbnail_height = $thumbnail_size * ($pic_height / $pic_width); + } + else + { + $thumbnail_height = $thumbnail_size; + $thumbnail_width = $thumbnail_size * ($pic_width / $pic_height); + } + + $thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height); + + $resize_function = 'imagecopyresampled'; + + $source = $read_function($pic_fullpath); + + @$resize_function($thumbnail, $source, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); + + + switch ($pic_filetype) + { + case '.gif': + imagegif($thumbnail); + break; + case '.jpeg': + case '.jpg': + case '.pjpeg': + imagejpeg($thumbnail); + break; + case '.png': + imagepng($thumbnail); + break; + default: + return false; + } + + imagedestroy($thumbnail); + + } header('Content-type: image/jpeg'); *************** *** 206,210 **** // -------------------------------- ! if( ($album_sp_config['midthumb_cache'] == 1) and ($pic_thumbnail != '') and file_exists(ALBUM_MED_CACHE_PATH . $pic_thumbnail) ) { switch ($pic_filetype) --- 282,286 ---- // -------------------------------- ! if( ($album_sp_config['midthumb_cache'] == 1) and ($pic_thumbnail != '') and file_exists($pic_med_fullpath) ) { switch ($pic_filetype) |