

donturner
Members-
Content count
5 -
Joined
-
Last visited
Profile Information
-
Real Name
Don Turner
-
'On the Fly' Auto Thumbnailer using GD Library
donturner replied to a topic in General Add-Ons Support
Must be something to do with the arguments you're sending to the function, add: print $src; immediately after: function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { In order to see what you're passing in, then check if that image exists and that the path is correct. You'll probably find that the path is wrong. Good luck, Don -
'On the Fly' Auto Thumbnailer using GD Library
donturner replied to a topic in General Add-Ons Support
This should work but I haven't tested it so no guarantees ;) Hope it helps! Don // "On the Fly" Auto Thumbnailer using GD Library originally Nate Welch (v1.5) Updated by various contributors (v1.7.1) // Scales product images dynamically, resulting in smaller file sizes, and keeps // proper image ratio. Used in conjunction with product_thumb.php t/n generator. function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { // Set default image variable and code $image = '<img src="' . $src . '"'; // Dont calculate if the image is set to a "%" width if (strstr($width,'%') == false || strstr($height,'%') == false) { $dont_calculate = 0; } else { $dont_calculate = 1; } // Do we calculate the image size? if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) { // Get the image information if ($image_size = @getimagesize($src)) { $ratio = $image_size[1] / $image_size[0]; // Set the width and height to the proper ratio if (!$width && $height) { $width = intval($height / $ratio); } elseif ($width && !$height) { $height = intval($width * $ratio); } elseif (!$width && !$height) { $width = $image_size[0]; $height = $image_size[1]; } $image = '<img src="product_thumb.php?img='.$src.'&w='.tep_output_string($width).'&h='.tep_output_string($height).'"'; } elseif (IMAGE_REQUIRED == 'false') { return ''; } else { //the image did not exist and it is required so return a default image $image = '<img src="'.DIR_WS_IMAGES.'notavailable.gif" '; } } // Add remaining image parameters if they exist if ($width) { $image .= ' width="' . tep_output_string($width) . '"'; } if ($height) { $image .= ' height="' . tep_output_string($height) . '"'; } if (tep_not_null($params)) $image .= ' ' . $params; $image .= ' border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title="' . tep_output_string($alt) . '"'; } $image .= '>'; return $image; } -
'On the Fly' Auto Thumbnailer using GD Library
donturner replied to a topic in General Add-Ons Support
Do a search for the line: imagejpeg($tmp_img, '', 100); in product_thumb.php The 100 part of that function call represents the image quality, drop it down to about 50 for a reduction in the JPEG quality and hence filesize. For more info check out imagejpeg on php.net -
'On the Fly' Auto Thumbnailer using GD Library
donturner replied to a topic in General Add-Ons Support
Can't see anything wrong with that, I would put: print "width: ".$width; print "height: ".$height; at the start of the function and track the values throughout to see where it's getting set to zero. Alternatively you could try this modified version of the function which I wrote, it takes out some redundant code used to calculate the ratio of height to width: // "On the Fly" Auto Thumbnailer using GD Library originally Nate Welch (v1.5) Updated by various contributors (v1.7.1) // Scales product images dynamically, resulting in smaller file sizes, and keeps // proper image ratio. Used in conjunction with product_thumb.php t/n generator. function tep_image($src, $alt = '', $width = '', $height = '', $params = '') { // Set default image variable and code $image = '<img src="' . $src . '"'; // Dont calculate if the image is set to a "%" width if (strstr($width,'%') == false || strstr($height,'%') == false) { $dont_calculate = 0; } else { $dont_calculate = 1; } // Do we calculate the image size? if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) { // Get the image information if ($image_size = @getimagesize($src)) { $ratio = $image_size[1] / $image_size[0]; // Set the width and height to the proper ratio if (!$width && $height) { $width = intval($height / $ratio); } elseif ($width && !$height) { $height = intval($width * $ratio); } elseif (!$width && !$height) { $width = $image_size[0]; $height = $image_size[1]; } $image = '<img src="product_thumb.php?img='.$src.'&w='.tep_output_string($width).'&h='.tep_output_string($height).'"'; } elseif (IMAGE_REQUIRED == 'false') { return ''; } } // Add remaining image parameters if they exist if ($width) { $image .= ' width="' . tep_output_string($width) . '"'; } if ($height) { $image .= ' height="' . tep_output_string($height) . '"'; } if (tep_not_null($params)) $image .= ' ' . $params; $image .= ' border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title="' . tep_output_string($alt) . '"'; } $image .= '>'; return $image; } -
'On the Fly' Auto Thumbnailer using GD Library
donturner replied to a topic in General Add-Ons Support
Hi rezdwan, The division by zero error is caused by the $width and $height variables being set to either null or empty string. Post your tep_image() function here and I'll take a look at it. Don