I'm not quite sure, but consider the following:

Considering the fact that most JPEG images are stored with some form of compression usually ~75% that would mean the original image, in actual size, is about 1.33x bigger than it appears in filesize. When you make a thumbnail, you limit the amount of pixels, but you are setting compression to 100% (besides that, you also use a truecolor pallete which adds to its size). So, for images which are scaled down less than 25% (actually this will prob. be more around 30-ish, due to palette differences) you'll actually see the thumbnail being bigger in *filesize* than the original (though smaller in memory-size)

- tul

P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ??

tedd wrote:
Hi gang:

I have a thumbnail script, which does what it is supposed to do. However, the thumbnail image generated is larger than the original image, how can that be?

Here's the script working:

http://xn--ovg.com/thickbox

And, here's the script:

<?php /* thumb from file */

/* some settings */
ignore_user_abort();
set_time_limit( 0 );
error_reporting( FATAL | ERROR | WARNING );

/* security check */
ini_set( 'register_globals', '0' );

/* start buffered output */
ob_start();

/* some checks */
if ( ! isset( $_GET['s'] ) ) die( 'Source image not specified' );

$filename = $_GET['s'];

// Set a maximum height and width
$width = 200;
$height = 200;

// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);

if ($width && ($width_orig < $height_orig))
    {
    $width = ($height / $height_orig) * $width_orig;
    }
else
    {
    $height = ($width / $width_orig) * $height_orig;
    }

// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);

//  Output & Content type
header('Content-type: image/jpeg');
imagejpeg($image_p, null, 100);

/* end buffered output */
ob_end_flush();
?>

---

Thanks in advance for any comments, suggestions or answers.

tedd


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to