|
From: Florin C B. <ory...@us...> - 2013-03-19 05:54:12
|
Update of /cvsroot/mxbb/mx_smartor/album_mod/modules In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10648/modules Modified Files: album_pic.php album_picm.php album_thumbnail.php album_upload.php Log Message: Album Image Class Update to partialy support the other type of images Index: album_picm.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/modules/album_picm.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** album_picm.php 19 Mar 2013 02:01:49 -0000 1.12 --- album_picm.php 19 Mar 2013 05:54:09 -0000 1.13 *************** *** 449,453 **** exit; } ! //$pic_fullpath = ALBUM_UPLOAD_PATH . $pic_filename; if (!@file_exists($pic_fullpath)) --- 449,461 ---- exit; } ! if (($pic_info['filetype'] == 'bmp') && @file_exists($pic_info['thumbnail_m_fullpath']) && ($album_config['show_gif_mid_thumb'] == 1)) ! { ! header('Content-type: image/bmp'); ! header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $pic_info['filetype']); ! $source = imagecreatefrompng($pic_info['thumbnail_m_fullpath']); ! //readfile($pic_info['thumbnail_m_fullpath']); ! imagebmp($source); ! exit; ! } //$pic_fullpath = ALBUM_UPLOAD_PATH . $pic_filename; if (!@file_exists($pic_fullpath)) *************** *** 530,533 **** --- 538,597 ---- } + + if ($pic_info['filetype'] == 'bmp') + { + $pic_med_fullpath = @file_exists($pic_med_fullpath) ? $pic_med_fullpath : $pic_fullpath; + // -------------------------------- + // GD does not support GIF so we must SEND a premade No-thumbnail pic then EXIT + // -------------------------------- + $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; + + $pic_size = @getimagesize($pic_med_fullpath); + $pic_width = $pic_size[0]; + $pic_height = $pic_size[1]; + + if ($pic_width > $pic_height) + { + $thumbnail_width = $album_sp_config['midthumb_width']; + $thumbnail_height = $album_sp_config['midthumb_width'] * ($pic_height/$pic_width); + } + else + { + $thumbnail_height = $album_sp_config['midthumb_height']; + $thumbnail_width = $album_sp_config['midthumb_height'] * ($pic_width/$pic_height); + } + $file_header = 'Content-type: image/png'; + header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $file_header); + $source = imagecreatefrombmp($pic_med_fullpath); + $thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height); + //$thumbnail = ($album_config['gd_version'] == 1) ? @imagecreate($thumbnail_width, $thumbnail_height) : @imagecreatetruecolor($thumbnail_width, $thumbnail_height); + $resize_function = 'imagecopyresampled'; + $resize_function($thumbnail, $source, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); + if ($album_config['midthumb_cache'] == true) + { + // ------------------------ + // Re-generate successfully. Write it to disk! + // ------------------------ + $pic_filetype = '.png'; + $pic_med_new = md5($pic_filename) . $pic_filetype; + $pic_med_new_fullpath = ALBUM_CACHE_PATH . $pic_med_new; + @imagepng($thumbnail, $pic_med_new_fullpath); + @chmod($pic_med_new_fullpath, 0777); + $sql = "UPDATE ". ALBUM_TABLE ." + SET pic_thumbnail = '" . $pic_med_new . "' + WHERE pic_id = '" . $pic_id . "'"; + if( !$result = $db->sql_query($sql) ) + { + mx_message_die(GENERAL_ERROR, 'Could not update pic information', '', __LINE__, __FILE__, $sql); + } + } + imagepng($thumbnail); + imagedestroy($thumbnail); + //readfile($pic_med_new_fullpath); + exit; + } + // ------------------------------------ // Send GD Thumbnail to browser Index: album_pic.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/modules/album_pic.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** album_pic.php 19 Mar 2013 02:01:49 -0000 1.11 --- album_pic.php 19 Mar 2013 05:54:09 -0000 1.12 *************** *** 434,438 **** $is_wm = (($apply_wm == true) && @file_exists($pic_info['thumbnail_w_f_fullpath'])) ? true : false; ! if (($pic_info['filetype'] == 'gif') || ((($pic_info['filetype'] == 'jpg') || ($pic_info['filetype'] == 'png')) && ($apply_wm == false)) || $is_wm) { header($file_header); --- 434,438 ---- $is_wm = (($apply_wm == true) && @file_exists($pic_info['thumbnail_w_f_fullpath'])) ? true : false; ! if (($pic_info['filetype'] == 'gif') || ($pic_info['filetype'] == 'bmp') || ($pic_info['filetype'] == 'xbm') || ($pic_info['filetype'] == 'wbmp') || ((($pic_info['filetype'] == 'jpg') || ($pic_info['filetype'] == 'png')) && ($apply_wm == false)) || $is_wm) { header($file_header); Index: album_upload.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/modules/album_upload.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** album_upload.php 19 Mar 2013 02:01:49 -0000 1.8 --- album_upload.php 19 Mar 2013 05:54:09 -0000 1.9 *************** *** 975,979 **** // Resize on upload ! if ( ((($pic_width > $album_config['max_width']) || ($pic_height > $album_config['max_height'])) || ($recompress == 1)) && ($pic_filetype != '.xbmp')) { if ($album_config['gd_version'] == 0) --- 975,979 ---- // Resize on upload ! if ( ((($pic_width > $album_config['max_width']) || ($pic_height > $album_config['max_height'])) || ($recompress == 1)) && ($pic_filetype != '.gif') && ($pic_filetype != '.xbm') && ($pic_filetype != '.bmp')) { if ($album_config['gd_version'] == 0) *************** *** 1092,1096 **** // Need to rotate before thumbnail cache // -------------------------------------- ! if( ($pic_filetype != '.gif') && ($album_config['gd_version'] > 0) && ($_POST['rotation'] > 0) && (!$HotLinked) && ($album_config['switch_nuffload'] == 0) ) { // Uncomment the next line if you want to rotate clockwise and remember to change the language setting --- 1092,1096 ---- // Need to rotate before thumbnail cache // -------------------------------------- ! if( ($pic_filetype != '.gif') && ($pic_filetype != '.xbm') && ($pic_filetype != '.bmp') && ($album_config['gd_version'] > 0) && ($_POST['rotation'] > 0) && (!$HotLinked) && ($album_config['switch_nuffload'] == 0) ) { // Uncomment the next line if you want to rotate clockwise and remember to change the language setting *************** *** 1101,1110 **** switch ($pic_filetype) { ! case '.jpg': ! $read_function = 'imagecreatefromjpeg'; ! break; case '.png': ! $read_function = 'imagecreatefrompng'; ! break; } --- 1101,1125 ---- switch ($pic_filetype) { ! case '.gif': ! $read_function = 'imageCreateFromGIF'; ! break; ! case '.jpeg': ! $read_function = 'imageCreateFromJPEG'; ! break; case '.png': ! $read_function = 'imageCreateFromPNG'; ! break; ! case '.xbm': ! $read_function = 'ImageCreateFromXBM'; ! break; ! case '.wbmp': ! $read_function = 'imageCreateFromWBMP'; ! break; ! case '.bmp': ! $read_function = 'ImageCreateFromBMP'; ! break; ! default: ! $ermsg = $pic_filetype .' images are not supported<br />'; ! break; } *************** *** 1125,1138 **** switch ($pic_filetype) { - case '.jpg': - @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); - @imagejpeg($rotate, ALBUM_UPLOAD_PATH . $pic_filename, $album_config['thumbnail_size']); - break; case '.png': @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); @imagepng($rotate, ALBUM_UPLOAD_PATH . $pic_resize); break; } - @chmod(ALBUM_UPLOAD_PATH . $pic_filename, 0777); $pic_size = getimagesize(ALBUM_UPLOAD_PATH . $pic_filename); --- 1140,1169 ---- switch ($pic_filetype) { case '.png': @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); @imagepng($rotate, ALBUM_UPLOAD_PATH . $pic_resize); break; + case 'gif': + @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); + @imagegif($rotate, ALBUM_UPLOAD_PATH . $pic_resize); + break; + case '.xbm': + @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); + @imagexbm($rotate, ALBUM_UPLOAD_PATH . $pic_resize); + break; + case '.wbmp': + @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); + @imagewbmp($rotate, ALBUM_UPLOAD_PATH . $pic_resize); + break; + case '.bmp': + @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); + @imagebmp($rotate, ALBUM_UPLOAD_PATH . $pic_resize); + break; + case '.jpg': + default: + @unlink(ALBUM_UPLOAD_PATH . $pic_rotate); + @imagejpeg($rotate, ALBUM_UPLOAD_PATH . $pic_filename, $album_config['thumbnail_size']); + break; } @chmod(ALBUM_UPLOAD_PATH . $pic_filename, 0777); $pic_size = getimagesize(ALBUM_UPLOAD_PATH . $pic_filename); *************** *** 1148,1152 **** // -------------------------------- ! if( ($album_config['thumbnail_cache'] == 1) && ($pic_filetype != '.gif') && ($album_config['gd_version'] > 0) ) { $gd_errored = false; --- 1179,1183 ---- // -------------------------------- ! if( ($album_config['thumbnail_cache'] == 1) && ($pic_filetype != '.gif') && ($pic_filetype != '.xbm') && ($pic_filetype != '.bmp') && ($album_config['gd_version'] > 0) ) { $gd_errored = false; *************** *** 1154,1163 **** switch ($pic_filetype) { ! case '.jpg': ! $read_function = 'imagecreatefromjpeg'; ! break; case '.png': ! $read_function = 'imagecreatefrompng'; ! break; } --- 1185,1209 ---- switch ($pic_filetype) { ! case '.gif': ! $read_function = 'imageCreateFromGIF'; ! break; ! case '.jpeg': ! $read_function = 'imageCreateFromJPEG'; ! break; case '.png': ! $read_function = 'imageCreateFromPNG'; ! break; ! case '.xbm': ! $read_function = 'ImageCreateFromXBM'; ! break; ! case '.wbmp': ! $read_function = 'imageCreateFromWBMP'; ! break; ! case '.bmp': ! $read_function = 'ImageCreateFromBMP'; ! break; ! default: ! $ermsg = $pic_filetype .' images are not supported<br />'; ! break; } *************** *** 1226,1229 **** --- 1272,1287 ---- @imagepng($thumbnail, ALBUM_CACHE_PATH . $pic_thumbnail); break; + case '.xbm': + @imagexbm($thumbnail, ALBUM_CACHE_PATH . $pic_thumbnail); + break; + case '.wbmp': + @imagewbmp($thumbnail, ALBUM_CACHE_PATH . $pic_thumbnail); + break; + case '.bmp': + @imagebmp($thumbnail, ALBUM_CACHE_PATH . $pic_thumbnail); + break; + default: + @imagejpeg($thumbnail, ALBUM_CACHE_PATH . $pic_thumbnail, '70'); + break; } @chmod(ALBUM_CACHE_PATH . $pic_thumbnail, 0777); *************** *** 1281,1285 **** // --- Smart Album Button BEGIN ---------------- // added by Tom XS2 Build 054 ! if ( defined('IS_PHPBBXS') ) { if ($is_personal_gallery == true) --- 1339,1343 ---- // --- Smart Album Button BEGIN ---------------- // added by Tom XS2 Build 054 ! if ( defined('IN_PORTAL') ) { if ($is_personal_gallery == true) Index: album_thumbnail.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/modules/album_thumbnail.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** album_thumbnail.php 18 Mar 2013 03:41:25 -0000 1.11 --- album_thumbnail.php 19 Mar 2013 05:54:09 -0000 1.12 *************** *** 270,274 **** $read_function = 'ReadSourceFile'; $send_function = 'SendToBrowser'; ! break; default: header('Content-type: image/jpeg'); --- 270,279 ---- $read_function = 'ReadSourceFile'; $send_function = 'SendToBrowser'; ! break; ! case '.bmp': ! $file_header = 'Content-type: image/bmp'; ! $read_function = 'ReadSourceFile'; ! $send_function = 'SendToBrowser'; ! break; default: header('Content-type: image/jpeg'); *************** *** 304,308 **** $read_function = 'imagecreatefrompng'; $send_function = 'imagepng'; ! break; default: header('Content-type: image/jpeg'); --- 309,318 ---- $read_function = 'imagecreatefrompng'; $send_function = 'imagepng'; ! break; ! case '.bmp': ! $file_header = 'Content-type: image/png'; ! $read_function = 'imagecreatefrombmp'; ! $send_function = 'imagepng'; ! break; default: header('Content-type: image/jpeg'); *************** *** 316,381 **** } // ------------------------------------ ! // Send GIF Thumbnail to browser // ------------------------------------ ! if (($pic_info['filetype'] == 'gif') && ($useclass = false)) { ! $pic_thumbnail = @file_exists($pic_thumbnail) ? $pic_thumbnail : $pic_fullpath; // -------------------------------- // GD does not support GIF so we must SEND a premade No-thumbnail pic then EXIT // -------------------------------- ! if ($album_config['show_gif_mid_thumb'] == 1) ! { ! $thumbnail_size = 500; ! $thumbnail_width = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 350; ! $thumbnail_height = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 350; ! ! $pic_size = @getimagesize($pic_thumbnail); ! $pic_width = $pic_size[0]; ! $pic_height = $pic_size[1]; ! ! if ($pic_width > $pic_height) ! { ! $thumbnail_width = $album_config['thumbnail_size']; ! $thumbnail_height = $album_config['thumbnail_size'] * ($pic_height/$pic_width); ! } ! else ! { ! $thumbnail_height = $album_config['thumbnail_size']; ! $thumbnail_width = $album_config['thumbnail_size'] * ($pic_width/$pic_height); ! } ! ! header($file_header); ! ! $thumbnail = ($album_config['gd_version'] == 1) ? @imagecreate($thumbnail_width, $thumbnail_height) : @imagecreatetruecolor($thumbnail_width, $thumbnail_height); ! ! $resize_function = 'imagecopyresampled'; ! ! $source = $read_function($pic_thumbnail); ! ! @$resize_function($thumbnail, $source, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); ! $send_function($thumbnail); ! ! imagedestroy($thumbnail); } else { ! header('Content-type: image/gif'); ! readfile($module_root_path . 'album_mod/nothumbnail.jpg'); ! exit; } ! } ! elseif (($pic_info['filetype'] == 'gif') && ($Image->$read_function($pic_thumbnail)) && ($album_config['show_gif_mid_thumb'] == 1)) ! { ! $Image->$send_function($pic_title_reg, $pic_filetype, '', '', $album_config['thumbnail_quality']); ! $Image->Destroy(); exit; - } elseif ($pic_info['filetype'] == 'gif') { ! header('Content-type: image/jpeg'); header("Content-Disposition: filename=thumb_" . $pic_title_reg . $pic_filetype); readfile($pic_nopic_fullpath); --- 326,399 ---- } + if (!@file_exists($pic_fullpath)) + { + //mx_message_die(GENERAL_ERROR, 'error: image file does not exists', '', __LINE__, __FILE__, $pic_fullpath); + $pic_fullpath = $pic_nopic_fullpath; //!empty($images['no_thumbnail']) ? $images['no_thumbnail'] : $module_root_path . 'templates/'. $theme['template_name'] . '/images/nothumbnail.jpg'; + } + // ------------------------------------ ! // Try send GIF Thumbnail to browser using GD Class // ------------------------------------ ! if ((($pic_info['filetype'] == 'gif') || ($pic_info['filetype'] == 'bmp')) && ($Image->$read_function($pic_thumbnail)) && ($album_config['show_gif_mid_thumb'] == 1)) { ! //$Image->$send_function($pic_title_reg, $pic_filetype, '', '', $album_config['thumbnail_quality']); ! //$Image->Destroy(); ! //exit; ! ! } ! // ------------------------------------ ! // Try send GIF/BMP Thumbnail to browser again ! // ------------------------------------ ! if (($pic_info['filetype'] == 'gif') && @file_exists($pic_info['pic_thumbnail'])) ! { ! header('Content-type: image/gif'); ! header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $pic_info['filetype']); ! readfile($pic_info['thumbnail_fullpath']); ! exit; ! } ! if ($pic_info['filetype'] == 'gif') ! { ! $pic_thumbnail = @file_exists($pic_info['pic_thumbnail']) ? $pic_info['pic_thumbnail'] : $pic_fullpath; // -------------------------------- // GD does not support GIF so we must SEND a premade No-thumbnail pic then EXIT // -------------------------------- ! $thumbnail_size = 500; ! $thumbnail_width = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 350; ! $thumbnail_height = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 350; ! $pic_size = @getimagesize($pic_thumbnail); ! $pic_width = $pic_size[0]; ! $pic_height = $pic_size[1]; + if ($pic_width > $pic_height) + { + $thumbnail_width = $album_config['thumbnail_size']; + $thumbnail_height = $album_config['thumbnail_size'] * ($pic_height/$pic_width); } else { ! $thumbnail_height = $album_config['thumbnail_size']; ! $thumbnail_width = $album_config['thumbnail_size'] * ($pic_width/$pic_height); } ! ! header($file_header); ! $thumbnail = ($album_config['gd_version'] == 1) ? @imagecreate($thumbnail_width, $thumbnail_height) : @imagecreatetruecolor($thumbnail_width, $thumbnail_height); ! $resize_function = 'imagecopyresampled'; ! $source = $read_function($pic_thumbnail); ! ! $resize_function($thumbnail, $source, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); ! ! $send_function($thumbnail); ! ! imagedestroy($thumbnail); ! ! //header('Content-type: image/png'); ! //header("Content-Disposition: filename=thumb_" . $pic_title_reg . $pic_filetype); ! //readfile($pic_nopic_fullpath); exit; } elseif ($pic_info['filetype'] == 'gif') { ! header('Content-type: image/png'); header("Content-Disposition: filename=thumb_" . $pic_title_reg . $pic_filetype); readfile($pic_nopic_fullpath); *************** *** 383,390 **** } ! if (!@file_exists($pic_fullpath)) ! { ! //mx_message_die(GENERAL_ERROR, 'error: image file does not exists', '', __LINE__, __FILE__, $pic_fullpath); ! $pic_fullpath = $pic_nopic_fullpath; //!empty($images['no_thumbnail']) ? $images['no_thumbnail'] : $module_root_path . 'templates/'. $theme['template_name'] . '/images/nothumbnail.jpg'; } --- 401,468 ---- } ! if (($pic_info['filetype'] == 'bmp') && @file_exists($pic_thumbnail_fullpath)) ! { ! header('Content-type: image/bmp'); ! header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $pic_info['filetype']); ! $source = imagecreatefrompng($pic_thumbnail_fullpath); ! //readfile($pic_thumbnail_fullpath); ! imagebmp($source); ! exit; ! } ! if ($pic_info['filetype'] == 'bmp') ! { ! $pic_thumbnail = @file_exists($pic_info['pic_thumbnail']) ? $pic_info['pic_thumbnail'] : $pic_fullpath; ! // -------------------------------- ! // GD does not support GIF so we must SEND a premade No-thumbnail pic then EXIT ! // -------------------------------- ! $thumbnail_size = 255; ! $thumbnail_width = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 255; ! $thumbnail_height = ($album_config['thumbnail_size']) ? $album_config['thumbnail_size'] : 255; ! ! $pic_size = @getimagesize($pic_thumbnail); ! $pic_width = $pic_size[0]; ! $pic_height = $pic_size[1]; ! ! if ($pic_width > $pic_height) ! { ! $thumbnail_width = $album_config['thumbnail_size']; ! $thumbnail_height = $album_config['thumbnail_size'] * ($pic_height/$pic_width); ! } ! else ! { ! $thumbnail_height = $album_config['thumbnail_size']; ! $thumbnail_width = $album_config['thumbnail_size'] * ($pic_width/$pic_height); ! } ! ! $file_header = 'Content-type: image/png'; ! header('Content-Disposition: filename=' . $pic_info['title_reg'] . '.' . $file_header); ! $source = imagecreatefrombmp($pic_fullpath); ! $thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height); ! $resize_function = 'imagecopyresampled'; ! $resize_function($thumbnail, $source, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height); ! if ($album_config['thumbnail_cache'] == 1) ! { ! // ------------------------ ! // Re-generate successfully. Write it to disk! ! // ------------------------ ! $pic_filetype = '.png'; ! $pic_thumbnail_new = md5($pic_filename) . $pic_filetype; ! $pic_thumbnail_new_fullpath = ALBUM_CACHE_PATH . $pic_thumbnail_new; ! @imagepng($thumbnail, $pic_thumbnail_new_fullpath); ! @chmod($pic_thumbnail_new_fullpath, 0777); ! $sql = "UPDATE ". ALBUM_TABLE ." ! SET pic_thumbnail = '" . $pic_thumbnail_new . "' ! WHERE pic_id = '" . $pic_id . "'"; ! if( !$result = $db->sql_query($sql) ) ! { ! mx_message_die(GENERAL_ERROR, 'Could not update pic information', '', __LINE__, __FILE__, $sql); ! } ! } ! //imagepng($thumbnail); ! imagedestroy($thumbnail); ! //readfile($pic_thumbnail_new_fullpath); ! //header("Content-Disposition: filename=thumb_" . $pic_title_reg . $pic_filetype); ! //readfile($pic_nopic_fullpath); ! exit; } *************** *** 487,490 **** --- 565,569 ---- @imagejpeg($thumbnail, $pic_thumbnail_new_fullpath, $album_config['thumbnail_quality']); break; + case '.bmp': case '.png': @imagepng($thumbnail, $pic_thumbnail_new_fullpath); *************** *** 503,506 **** --- 582,586 ---- break; case '.png': + case '.bmp': @imagepng($thumbnail); break; |