Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

'On the Fly' Auto Thumbnailer using GD Library


Guest

Recommended Posts

Hi Guys,

 

I have a slight problem that I hope you can help me with.

 

So far the my thumbnails are looking great all thanks to this contribution, however I am also using the define main page contrib as well and I am trying to add this code to the main page.

 

CODE<?php  echo '<a href="' . tep_href_link('product_info.php?products_id=664') . '">' . tep_image(DIR_WS_IMAGES . 'HKP-500a.gif', SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

 

 

The problem is, is that this pic is not picked up and converted to a thumbnail!

 

Can anyone tell me how to fix this because I dont really want to use the full size image!

 

Thanks

 

Mark

 

Anyone have any ideas on how I can get this sorted please!

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

  • Replies 313
  • Created
  • Last Reply

Top Posters In This Topic

hi i am getting this small error when I activate inactive products,

 

Warning: Division by zero in /hsphere/local/home/slammink/slamminkicks.com/newshop/includes/functions/html_output.php on line 123

 

Warning: Division by zero in /hsphere/local/home/slammink/slamminkicks.com/newshop/includes/functions/html_output.php on line 124

 

This is the offending image url: http://slamminkicks.com/newshop/product_th...ure.gif&w=0&h=0

 

Any thoughts plz?

Link to comment
Share on other sites

Hello all and anyone who can help...

 

Nate this is exactly the contribution we desperately need - thank you VERY much!!!

 

I've been struggling with this for a couple of days and as soon as I think I have it figured out, I... uhhhh.... don't...

 

 

 

Issue:

 

 

1) I do not have a "catalog" folder on my root - from what I understand this a catalog folder is not always necessary if OS is on your root - I do not think this makes a difference for this contribution but it looks like it might on a shipping contribution I'm working on so I need someone to please advise -

my paths for installation go as follows:

for Product Thumb: public_html/os_commerce/product_thumb.php

for HTML_Output: public_html/os_commerce/includes/functions/html_output.php

 

 

2) I am trying to display baseball bats as a thumb but nothing seems to have worked - please look over my html_output and advise if anything is incorrect (see below)

Link to bats: http://216.120.249.43/osCommerce/index.php...e30aa938245b634

 

 

3) If html_output is correct, is there something else I'm missing?

 

 

 

 

////

// The HTML href link wrapper function

function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {

global $request_type, $session_started, $SID;

 

if (!tep_not_null($page)) {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');

}

 

if ($connection == 'NONSSL') {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

} elseif ($connection == 'SSL') {

if (ENABLE_SSL == true) {

$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

} else {

$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

}

} else {

die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');

}

 

if (tep_not_null($parameters)) {

$link .= $page . '?' . tep_output_string($parameters);

$separator = '&';

} else {

$link .= $page;

$separator = '?';

}

 

while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined

if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {

if (tep_not_null($SID)) {

$_sid = $SID;

} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {

if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

$_sid = tep_session_name() . '=' . tep_session_id();

}

}

}

 

if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {

while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

 

$link = str_replace('?', '/', $link);

$link = str_replace('&', '/', $link);

$link = str_replace('=', '/', $link);

 

$separator = '?';

}

 

if (isset($_sid)) {

$link .= $separator . $_sid;

}

 

return $link;

}

 

////

// Modified tep_image function to keep proper ratio and use GD Library (in conjunction

// with product_thumb.php for image resizing. Requires PHP GD Image Library version 2+

function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

 

if (($src == '' || $src == 'images/') && IMAGE_REQUIRED == 'false') {

return;

}

 

$image = '<img src="' . $src . '" border="0" alt=" ' . htmlspecialchars(StripSlashes($alt)) . ' " title=" ' . htmlspecialchars(StripSlashes($alt)) . ' "';

 

if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) {

$dont_calculate = 1;

}

 

if (CONFIG_CALCULATE_IMAGE_SIZE && (!$width || !$height) && !$dont_calculate) {

 

if ($image_size = @getimagesize($src)) {

 

if (!$width && $height) {

$ratio = $height / $image_size[1];

$width = $image_size[0] * $ratio;

} elseif ($width && !$height) {

$ratio = $width / $image_size[0];

$height = $image_size[1] * $ratio;

} elseif (!$width && !$height) {

$width = $image_size[0];

$height = $image_size[1];

}

} elseif (IMAGE_REQUIRED == 'false') {

 

return '';

}

}

 

if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) {

 

if ($image_size = @getimagesize($src)) {

 

$ratio = $image_size[1] / $image_size[0]; // real ratio

 

$orig_width = $image_size[1];

$orig_height = $image_size[0];

 

// do we need scaling

if ($image_size[0] > $width || $image_size[1] > $height) {

$rx = $image_size[0] / $width;

$ry = $image_size[1] / $height;

 

if ($rx < $ry) {

$width = $height / $ratio;

} else {

$height = $width * $ratio;

}

 

// Generate thumbnail on the fly

$image = '<img src="product_thumb.php?img='.$src.'&w='.intval($width).'&h='.intval($height).'" border="0" alt=" ' . htmlspecialchars(StripSlashes($alt)) . ' " title=" ' . htmlspecialchars(StripSlashes($alt)) . ' "';

 

}

}

}

 

if (!$dont_calculate) {

$width = intval($width);

$height = intval($height);

}

 

if ($width && $height) {

$image .= ' width="' . $width . '" height="' . $height . '"';

}

 

if ($params != '') {

$image .= ' ' . $params;

}

 

$image .= '>';

 

return $image;

}

 

////

// The HTML form submit button wrapper function

// Outputs a button in the selected language

function tep_image_submit($image, $alt = '', $parameters = '') {

global $language;

 

$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

 

if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

 

$image_submit .= '>';

 

return $image_submit;

}

 

////

// Output a function button in the selected language

function tep_image_button($image, $alt = '', $parameters = '') {

global $language;

 

return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);

}

 

 

Thank you VERY much,

 

Doug

Link to comment
Share on other sites

Hi,

 

I'm really sorry to ask what is such an obvious question, but what is/where is the tep_image function? Searching inside the text of all the code brings up most php files, do I have to replace it in each and everyone? Or if not, where?

 

I'm learning fast with this (I have to!), but this stumped me! Any help would be grstefully recieved.

 

Many thanks,

 

Nick,

Link to comment
Share on other sites

*catalog*/includes/functions/html_output.php

 

Thank you for the lightening quick reply! After I saw your post, I read the readme.txt for the uptenth time & there was the answer to my question staring right at me. Doh. My bad!

& Nath, thanks for the mod, a very useful addition to my website, a time saving piece of wonder-code. Yum. Cheers mate.

Link to comment
Share on other sites

Bump!!!

 

Can anyone help with this PLEASE!!! Getting close to production time!!!

 

 

Thanks so much

 

 

 

 

 

Hello all and anyone who can help...

 

Nate this is exactly the contribution we desperately need - thank you VERY much!!!

 

I've been struggling with this for a couple of days and as soon as I think I have it figured out, I... uhhhh.... don't...

Issue:

1) I do not have a "catalog" folder on my root - from what I understand this a catalog folder is not always necessary if OS is on your root - I do not think this makes a difference for this contribution but it looks like it might on a shipping contribution I'm working on so I need someone to please advise -

my paths for installation go as follows:

for Product Thumb:  public_html/os_commerce/product_thumb.php

for HTML_Output:    public_html/os_commerce/includes/functions/html_output.php

2) I am trying to display baseball bats as a thumb but nothing seems to have worked - please look over my html_output and advise if anything is incorrect (see below)

Link to bats: http://216.120.249.43/osCommerce/index.php...e30aa938245b634

3) If html_output is correct, is there something else I'm missing?

////

// The HTML href link wrapper function

  function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {

    global $request_type, $session_started, $SID;

 

    if (!tep_not_null($page)) {

      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>');

    }

 

    if ($connection == 'NONSSL') {

      $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

    } elseif ($connection == 'SSL') {

      if (ENABLE_SSL == true) {

        $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;

      } else {

        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;

      }

    } else {

      die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br><br>');

    }

 

    if (tep_not_null($parameters)) {

      $link .= $page . '?' . tep_output_string($parameters);

      $separator = '&';

    } else {

      $link .= $page;

      $separator = '?';

    }

 

    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);

 

// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined

    if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {

      if (tep_not_null($SID)) {

        $_sid = $SID;

      } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {

        if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {

          $_sid = tep_session_name() . '=' . tep_session_id();

        }

      }

    }

 

    if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {

      while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);

 

      $link = str_replace('?', '/', $link);

      $link = str_replace('&', '/', $link);

      $link = str_replace('=', '/', $link);

 

      $separator = '?';

    }

 

    if (isset($_sid)) {

      $link .= $separator . $_sid;

    }

 

    return $link;

  }

 

////

// Modified tep_image function to keep proper ratio and use GD Library (in conjunction

// with product_thumb.php for image resizing. Requires PHP GD Image Library version 2+

function tep_image($src, $alt = '', $width = '', $height = '', $params = '') {

 

    if (($src == '' || $src == 'images/') && IMAGE_REQUIRED == 'false') {

        return;

    }

 

    $image = '<img src="' . $src . '" border="0" alt=" ' . htmlspecialchars(StripSlashes($alt)) . '  " title=" ' . htmlspecialchars(StripSlashes($alt)) . ' "';

 

    if ((strstr($width,'%')!='') || (strstr($height,'%')!='')) {

        $dont_calculate = 1;

    }

 

    if (CONFIG_CALCULATE_IMAGE_SIZE && (!$width || !$height) && !$dont_calculate) {

 

        if ($image_size = @getimagesize($src)) {

 

            if (!$width && $height) {

                $ratio = $height / $image_size[1];

                $width = $image_size[0] * $ratio;

            } elseif ($width && !$height) {

                $ratio = $width / $image_size[0];

                $height = $image_size[1] * $ratio;

            } elseif (!$width && !$height) {

                $width = $image_size[0];

                $height = $image_size[1];

            }

        } elseif (IMAGE_REQUIRED == 'false') {

 

        return '';

        }

    }

 

    if (CONFIG_CALCULATE_IMAGE_SIZE && !$dont_calculate) {

 

        if ($image_size = @getimagesize($src)) {

 

            $ratio = $image_size[1] / $image_size[0]; // real ratio

 

      $orig_width = $image_size[1];

      $orig_height = $image_size[0];

 

            // do we need scaling

            if ($image_size[0] > $width || $image_size[1] > $height) {

                $rx = $image_size[0] / $width;

                $ry = $image_size[1] / $height;

 

                if ($rx < $ry) {

                    $width = $height / $ratio;

                } else {

                    $height = $width * $ratio;

                }

 

                // Generate thumbnail on the fly

        $image = '<img src="product_thumb.php?img='.$src.'&w='.intval($width).'&h='.intval($height).'" border="0" alt=" ' . htmlspecialchars(StripSlashes($alt)) . ' " title=" ' . htmlspecialchars(StripSlashes($alt)) . ' "';

 

            }

        }

    }

 

  if (!$dont_calculate) {

    $width = intval($width);

    $height = intval($height);

  }

 

    if ($width && $height) {

        $image .= ' width="' . $width . '" height="' . $height . '"';

    }

 

    if ($params != '') {

        $image .= ' ' . $params;

    }

 

    $image .= '>';

 

    return $image;

}

 

////

// The HTML form submit button wrapper function

// Outputs a button in the selected language

  function tep_image_submit($image, $alt = '', $parameters = '') {

    global $language;

 

    $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

    if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

 

    if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

 

    $image_submit .= '>';

 

    return $image_submit;

  }

 

////

// Output a function button in the selected language

  function tep_image_button($image, $alt = '', $parameters = '') {

    global $language;

 

    return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);

  }

Thank you VERY much,

 

Doug

Link to comment
Share on other sites

I just finished installing the contribution and I'm receiving the following error...

 

"'Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virginia/public_html/shop/includes/functions/html_output.php:355) in /home/virginia/public_html/shop/includes/functions/sessions.php on line 67"

 

Is the error in the sessions.php file?

 

Any idea how I can find the error? The images are correctly being sized but I get that error at the top. Help would be much appreciated.

 

Jeremy

Link to comment
Share on other sites

I just finished installing the contribution and I'm receiving the following error...

 

"'Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/virginia/public_html/shop/includes/functions/html_output.php:355) in /home/virginia/public_html/shop/includes/functions/sessions.php on line 67"

 

Is the error in the sessions.php file?

 

Any idea how I can find the error?? The images are correctly being sized but I get that error at the top.? Help would be much appreciated.

 

Jeremy

That's easy to fix. The text editor you was using added extra lines after the ending "?>" just go into html_output.php and take off the extra lines after that.

 

Now for my problem. :P. I installed this contribution (latest version on contribution page) It works fine except with SOME of the image thumbs. Some of them are blank white with (in small letters on top left) the word Error. Here are my settings in product_thumb.php:

$use_resampling = true;

$use_truecolor = true;

$gif_as_jpeg = true;

$tn_cache = false;

$allow_larger = false; // The default is false.

$show_original = true; // The default is true.

 

No matter what settings i changed, it didn't take the errors away.

 

Apache 1.3.33

PHP 4.3.9

 

And for my GD:

gd
GD Support ?enabled ?
GD Version ?bundled (2.0.28 compatible) ?
GIF Read Support ?enabled ?
GIF Create Support ?enabled ?
JPG Support ?enabled ?
PNG Support ?enabled ?
WBMP Support ?enabled ?
XBM Support ? ? ? ?enabled

Edited by l3ean
Link to comment
Share on other sites

  • 1 month later...

Anyone solved the cache issue? When it is enabled, it does not pull the caches thumbnails.

It involves this code I think:

// Create appropriate image header
if ($image[2] == 2 || ($image[2] == 1 && $gif_as_jpeg)) {
   header('Content-type: image/jpeg');
if ($tn_cache) $filename = $_GET['img'] . ".thumb.jpg"; 
} elseif ($image[2] == 1 && function_exists(imagegif)) {
   header('Content-type: image/gif');
   if ($tn_cache) $filename = $_GET['img'] . ".thumb.gif";
}  elseif ($image[2] == 3 || $image[2] == 1) {
   header('Content-type: image/png');
   if ($tn_cache) $filename = $_GET['img'] . ".thumb.png"; 
}

Edited by crash resistant
Link to comment
Share on other sites

  • 4 weeks later...

Hey. I was reading this thread from the beginning, hoping my problem was addressed and solved ahead of time, and found out it was addressed, but not solved. But I think I inadvertantly figured it out, so I'm going to share, in case no one else came up with it (I stopped about half way though, when the topic moved away from it)

 

The problem was that images weren't resizing propotionally. But only some of them. Others seemed to work fine (and the ones that worked had the correct file names, the ones that didn't had their original names).

 

I thought it was because the product line that worked were long pictures, and the ones that didn't were tall. Now I think it's because my partner entered the other product line. He uses AOL. He seems to have saved all the images he's using in AOL's .ART format, which explorer will display, but I don't believe your contrib will do anything with but pass through. Which would explain the problem.

 

I'm going to get the images in jpg or gif format, and see if that fixes it, but I though it might help anyone who can't figure out the problem, and definitely give some insight to the programmers.

Link to comment
Share on other sites

I have this contribution install and it works great. However, I may have a small problem that may be related by may not be.

 

I can no longer upload new images to directoryname/image.jpg

 

It could be a directory permission problem but I haven't noticed it before. Anyone else having this problem.

Link to comment
Share on other sites

Dumb question time, added the contrib, works great, but how do you stop the jpg thumbnails appearing in a ceaper colour rather than the actual colour? Works fine for gif's, I think it may be a GD setting rather than the contrib (?)

cheers

Steve

Link to comment
Share on other sites

I've actually come back looking for an answer to that same problem. A few of my thumbs (seems to occur more in the double sized ones) are using awful looking colors. Usually washed with yellow or red across the entire image. How do I stop this?

Link to comment
Share on other sites

I would really like to see this conribution works in the Admin as well.

I tried repeating the istallation in the admin folders, but it didn't change a thing.

 

Any ideas?

 

thank you.

Link to comment
Share on other sites

  • 4 months later...

Hello everyone.

 

Sorry if this question had been asked before. Can't find my answer through the search.

 

I have installed the 'On the Fly' Auto Thumbnailer using GD Library 1.9.1. Everything seems to work fine except that I kept getting this error message on top of the shop.

Warning: Division by zero in /home/username/public_html/catalog/functions/html_output.php on line 158

 

Warning: Division by zero in /home/username/public_html/catalog/includes/functions/html_output.php on line 159

They are referring to the following lines in includes/functions/html_output.php.

	$rx = $image_size[0] / $width; 
$ry = $image_size[1] / $height;

I have set the Images Configuration as follow.

Small Image Width: 100

Small Image Height: 100

Heading Image Width: 80

Heading Image Height: 80

Subcategory Image Width: 80

Subcategory Image Height: 80

Calculate Image Size: true

Image Required: true

Has anyone encountered the same problem or will be able to tell me where have I gone wrong? All help is greatly appreciated.

 

Thanks

Link to comment
Share on other sites

Hello everyone.

 

Sorry if this question had been asked before. Can't find my answer through the search.

 

I have installed the 'On the Fly' Auto Thumbnailer using GD Library 1.9.1. Everything seems to work fine except that I kept getting this error message on top of the shop.

 

They are referring to the following lines in includes/functions/html_output.php.

	$rx = $image_size[0] / $width; 
$ry = $image_size[1] / $height;

I have set the Images Configuration as follow.

 

Has anyone encountered the same problem or will be able to tell me where have I gone wrong? All help is greatly appreciated.

 

Thanks

 

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

Link to comment
Share on other sites

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

Hello Don

 

I followed the instructions in the contribution as provided. Added the tep_image() to my stock html_output.php. So, I'm not sure where I have gone wrong. Here it is.

// "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 . '"';

 

 // Don't 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's 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) { 

$ratio = $height / $image_size[1]; 

$width = intval($image_size[0] * $ratio); 

     } elseif ($width && !$height) { 

$ratio = $width / $image_size[0]; 

$height = intval($image_size[1] * $ratio); 

     } elseif (!$width && !$height) { 

$width = $image_size[0]; 

$height = $image_size[1]; 

     } 

     

     // Scale the image if not the original size

     if ($image_size[0] != $width || $image_size[1] != $height) { 

$rx = $image_size[0] / $width; 

$ry = $image_size[1] / $height; 



if ($rx < $ry) { 

  $width = intval($height / $ratio); 

} else { 

  $height = intval($width * $ratio); 

} 



$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; 

}

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

Is there anyway to make OTF output low quality JPGs because the thumbnails which are output by OTF are still large in file size (around 8kb) for 80X56 compared to standard thumbnails at eBay around the same thumbnail size but much small file size (around 3kb) Please help!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...