diff --git a/ChangeLog b/ChangeLog index fcbd075f5..fd41c48c2 100755 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,10 @@ $Source$ 2003-03-05 Marc Delisle * Documentation.html, faq 1.29 about the "duplicate field names" problem + * transformation_wrapper.php3, libraries/defines_php.lib.php3, + libraries/transformations/image_jpeg__inline.inc.php3: + resized thumbnails + TODO: doc 2003-03-03 Alexander M. Turek * tbl_replace_fields.php3: Bugfix: User was unable to insert values diff --git a/libraries/defines_php.lib.php3 b/libraries/defines_php.lib.php3 index 6ceea85cc..a28da9181 100644 --- a/libraries/defines_php.lib.php3 +++ b/libraries/defines_php.lib.php3 @@ -10,6 +10,7 @@ * 40006 instead of 4.0.6RC3 * PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows * server + * PMA_IS_GD2 (bool) - true is GD2 is present */ // phpMyAdmin release if (!defined('PMA_VERSION')) { @@ -45,5 +46,19 @@ if (!defined('PMA_IS_WINDOWS')) { } } +// Whether GD2 is present +if (!defined('PMA_IS_GD2')) { + if (function_exists("get_extension_funcs")) { + $testGD = @get_extension_funcs("gd"); + if ($testGD && in_array("imagegd2",$testGD)) { + define('PMA_IS_GD2', 1); + } else { + define('PMA_IS_GD2', 0); + } + unset($testGD); + } else { + define('PMA_IS_GD2', 0); + } +} // $__PMA_DEFINES_PHP_LIB__ ?> diff --git a/libraries/transformations/image_jpeg__inline.inc.php3 b/libraries/transformations/image_jpeg__inline.inc.php3 index 49deecc49..9505c26a1 100644 --- a/libraries/transformations/image_jpeg__inline.inc.php3 +++ b/libraries/transformations/image_jpeg__inline.inc.php3 @@ -4,11 +4,16 @@ if (!defined('PMA_TRANSFORMATION_IMAGE_JPEG__INLINE')){ define('PMA_TRANSFORMATION_IMAGE_JPEG__INLINE', 1); - + function PMA_transformation_image_jpeg__inline($buffer, $options = array()) { include('./libraries/transformations/global.inc.php3'); - $transform_options = array ('string' => '[__BUFFER__]'); + if (PMA_IS_GD2) { + //$transform_options = array ('string' => '[__BUFFER__]'); + $transform_options = array ('string' => '[__BUFFER__]'); + } else { + $transform_options = array ('string' => '[__BUFFER__]'); + } $buffer = PMA_transformation_global_html_replace($buffer, $transform_options); return $buffer; diff --git a/transformation_wrapper.php3 b/transformation_wrapper.php3 index bccc53516..42f6a41be 100644 --- a/transformation_wrapper.php3 +++ b/transformation_wrapper.php3 @@ -28,7 +28,7 @@ $cfgRelation = PMA_getRelationsParam(); if (!empty($message)) { if (isset($goto)) { $goto_cpy = $goto; - $goto = 'tbl_properties.php3?' + $goto = 'tbl_properties.php3?' . PMA_generate_common_url($db, $table) . '&$show_query=1' . '&sql_query=' . urlencode($disp_query); @@ -53,7 +53,6 @@ if (!empty($message)) { } } - /** * Defines the url to return to in case of error in a sql statement */ @@ -138,6 +137,7 @@ if ($cfgRelation['commwork'] && $cfgRelation['mimework']) { * Sends http headers */ // Don't use cache (required for Opera) +if (!isset($noheader)) { $GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT'; header('Expires: ' . $GLOBALS['now']); // rfc2616 - Section 14.21 header('Last-Modified: ' . $GLOBALS['now']); @@ -146,8 +146,44 @@ header('Pragma: no-cache'); // HTTP/1.0 // [MIME] $content_type = 'Content-Type: ' . (isset($mime_map[urldecode($transform_key)]['mimetype']) ? str_replace("_", "/", $mime_map[urldecode($transform_key)]['mimetype']) : $default_ct) . (isset($mime_options['charset']) ? $mime_options['charset'] : ''); header($content_type); +} -echo $row[urldecode($transform_key)]; +if (!isset($resize)) { + echo $row[urldecode($transform_key)]; +} else { + // if image_jpeg__inline.inc.php3 finds that we can resize, + // it sets $resize to 1 + + $srcImage = imagecreatefromstring($row[urldecode($transform_key)]); + $newWidth = $suggested_size; + $newHeight = $suggested_size; + $srcWidth = ImageSX( $srcImage ); + $srcHeight = ImageSY( $srcImage ); + + // the following portion of code checks to see if + // the width > height or if width < height + // if so it adjusts accordingly to make sure the image + // stays smaller then the $newWidth and $newHeight + + $ratioWidth = $srcWidth/$newWidth; + $ratioHeight = $srcHeight/$newHeight; + + if( $ratioWidth < $ratioHeight){ + $destWidth = $srcWidth/$ratioHeight; + $destHeight = $newHeight; + }else{ + $destWidth = $newWidth; + $destHeight = $srcHeight/$ratioWidth; + } + + $destImage = ImageCreateTrueColor( $destWidth, $destHeight); + ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight ); + + ImageJPEG( $destImage,"",75 ); + ImageDestroy( $srcImage ); + ImageDestroy( $destImage ); + +} /** * Close MySql non-persistent connections