Jump to content
Rickharris

'On the Fly' Auto Thumbnailer using GD Library

Recommended Posts

Refer to above troubleshooting tips... If the contrib is being called, the images will resize...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

I just noticed my server error log is loaded with tens of thousands of this or similiar error messages. I am using GD Version bundled (2.0.17 compatible) with resampling, true color and jpg all congigured as true.

 

[Tue Oct 5 10:23:45 2004] [error] PHP Notice: Use of undefined constant imagecopyresampled - assumed 'imagecopyresampled' in /usr/home/user/public_html/catalog/product_thumb.php on line 68

 

Anyone have an idea as to what I have done wrong??

Share this post


Link to post
Share on other sites

I reduced my error level to zero "0", nill. Thus no more errors reported. Doesn't solve the problem however.

Share this post


Link to post
Share on other sites
It would be helpful to see a link and an example...  The most likely cause is that you are trying to thumbnail an unsupported file format (only PNG, GIF, and JPG are supported) or that your catalog config, with respect to the image directory is not set correctly.

 

It may also be you have your PHP's errors message turned all the way up on your machine, which is causing the problem... For each call to the thumbnailer, it is trying to output an "undefined variable" message before it makes the thumbnail which may be causing the images not to show up.  (If you call the product_thumb.php by itself, naturally you will get some errors as it is expecting info to be passed along to it)

 

You could try adjusting your PHP's error message settings so they only output *fatal* error warning messages or alter the script to implicity define every variable at the beginning (I know a better, if somewhat outdated PHP coding practice).

 

 

Nate,

 

sorry for the delay in replying, been busy with work.

 

I went and uploaded this to my website for testing, and I get the same thing. Just boxes with little red x's.

I have tried all the combos for turning on and off the options in config, etc...

 

I "believe" my directory is correct. my pictures are located in catalog/images/ (the default location on oscommerce install).

 

The pictures are in .jpg format so shouldn't be an issue.

 

I did a call to the php file to see if there were any errors and this is what I got.

 

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/mutzig2/public_html/catalog/product_thumb.php on line 73

 

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 77

 

Warning: imagefill(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 79

 

Warning: imagecolortransparent(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 80

 

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 93

 

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 111

 

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/mutzig2/public_html/catalog/product_thumb.php on line 112

 

The web host I am using has this version of gd installed:

 

gd

GD Support enabled

GD Version bundled (2.0.23 compatible)

FreeType Support enabled

FreeType Linkage with freetype

GIF Read Support enabled

JPG Support enabled

PNG Support enabled

WBMP Support enabled

XBM Support enabled

 

 

I just don't see what the problem could be? any ideas?

 

The website is located here

www.mutzigcreations.com (just adding to it, and getting ready to open it.)

 

I don't know if this would affect it or not, but I do have the UltraPics contribution installed.

 

Hope this helps, and thank you for your hard work, and time.

 

Doug


A man who works with his hands is a laborer

A man who works with his hands and his brain is a craftsman

But a man who works with his hands and his brain and his heart is an artist. - Charles Dickens

Share this post


Link to post
Share on other sites

Hi Nate.

 

I am a big fan of your contribution. I really like the fact that it resizes the images on the fly.

 

I too would like to see this contribution work with the UltraPics contribution.

 

In that vein I get broken images when I install the UltraPics contrib, and then yours. I get these kinds of image tags on new items. :blink:

<img src="product_thumb.php?img=images/homeworld2/boxcover-sm.jpg&w=75&h=100" width="75" height="100" border="0" alt=" Homeworld 2 " title=" Homeworld 2 ">

 

I haven't been able to figure out why the product_thumb.php didn't get executed. It looks to me like everything is set, and the file just doesn't get called.

Can you give me any clues to fix this?

 

Maybe we could incorporate all of the code in product_thumb.php into the tep_image function? :-"

 

Thanks for any help.

Share this post


Link to post
Share on other sites

hi

 

I'm a n00b trying to install this mod. I have a very silly question to ask that will make you slap your forehead repeatedly.

 

in the readme.txt file it says to replace the nep_image function with the provided code.

 

my question is: what is the tep_image function? From where to where to I replace code?

 

do I replace this with the provided code?

 

////

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

  }

 

Sorry for the silly question.

 

Thanks for any info :blush:

Share this post


Link to post
Share on other sites

Hi, look after the word function for the function name, which is followed by stuff in parenthesis. The one you have listed below is "tep_image_submit", you want the one in html_output.php (the same file, I think) called tep_image which does the formatting/output of images on the site.

 

You then replace the whole function, much as you have below, beginning with function... and ending with return... }

 

Also, check your store config to make sure the path to your images is correctly specified...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites
Hi, look after the word function for the function name, which is followed by stuff in parenthesis. The one you have listed below is "tep_image_submit", you want the one in html_output.php (the same file, I think) called tep_image which does the formatting/output of images on the site.

 

You then replace the whole function, much as you have below, beginning with function... and ending with return... }

 

Also, check your store config to make sure the path to your images is correctly specified...

 

thanks for the reply

I understand what you mean about the tep_image function now

but do i replace this?:

////

// The HTML image wrapper function

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

    if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {

      return false;

    }

 

// alt is added to the img tag even if it is null to prevent browsers from outputting

// the image filename as default

    $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

    if (tep_not_null($alt)) {

      $image .= ' title=" ' . tep_output_string($alt) . ' "';

    }

 

    if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {

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

        if (empty($width) && tep_not_null($height)) {

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

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

        } elseif (tep_not_null($width) && empty($height)) {

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

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

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

          $width = $image_size[0];

          $height = $image_size[1];

        }

      } elseif (IMAGE_REQUIRED == 'false') {

        return false;

      }

    }

 

    if (tep_not_null($width) && tep_not_null($height)) {

      $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';

    }

 

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

 

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

  }

until

return $image;

or

return $image_submit;

 

thanks!

Share this post


Link to post
Share on other sites

You see this?

////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
 function tep_image_submit($image, $alt = '', $parameters = '') {

... that's the start of a new function...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

thank you nate, I understand completely.

Thanks for answering my question!

Edited by lsd_se

Share this post


Link to post
Share on other sites

I have many stores that pull the pics out of one images folder, like a consolidated images folder. It seems this contribution only works if the images folder is the subfolder of the catalogue (../catalog/images). Can this be modified so that images are create on the fly no matter where the images folder is located?

Share this post


Link to post
Share on other sites

this might be the wrong asnwer, but if the configuration file lists the /images/yourpicturedirectory it should work, no?

Share this post


Link to post
Share on other sites

i wish it were that easy. for some reason it insists on only creating thumbnails only if the folder is a subfolder. its a weird thing, but if anyone has any idea, please let me know.

Share this post


Link to post
Share on other sites
Howdy all,

 

I just installed this contribution, but I seem to be getting several errors.

 

when I go to the site all I get are little red x's, if I do the click to enlarge then I can see my pictures.

 

i have the same problem RavenWulf, dod you get it fixed on your site yet?

It worked for the first page I looked at, and then after I just got red X's. strange.

Thanks

Edited by lsd_se

Share this post


Link to post
Share on other sites

also, could I ask if this is right in the file renaming?

in the same driectory I have the thumbnails generated as:

 

original: book-bleachers.jpg

thumb: book-bleachers.jpg.thumb.jpg

 

i have red x;'s all over the place, and I double checked my config settings which are correct. /catalog/, images/ etc.

Share this post


Link to post
Share on other sites

OK, i figured out the problem, but I don't know how to fix it.

The problem is my cache, it is generating the thumbs, but can't access them after.

I have cache set to false in my product_thumbs.php config now and it works fine.

 

How should I proceed in fixing this?

Edited by lsd_se

Share this post


Link to post
Share on other sites

I'm not sure what cache setting your are referring to - perhaps it is the hacked version of this contrib that saves the thumbnails as files?


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

yes, thumbnails have been generated like this in the same directory as the original image:

 

original: book-bleachers.jpg

thumb: book-bleachers.jpg.thumb.jpg

 

the settings in product_thumbs.php include a cache setting.

 

why do you say it's a hacked version? is it not a contribution from this site?

Share this post


Link to post
Share on other sites

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.

 

<?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 :-" :'(


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

Share this post


Link to post
Share on other sites

this doesn't work when images are in subfolders. It only works when images are just in the images folder. Anybody see why this would be happening?

Share this post


Link to post
Share on other sites

I think because the tep_image function uses whatever you have defined as your image path to look for the image...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

thanks for the reply. but more specifically, the problem is that the contribution will not generate a thumbnail on the fly if the image resides in a subfolder. It just ignores it.

Share this post


Link to post
Share on other sites

Hi I noticed a problem with this contribution. If a product image filename has a '&' in it, the thumbnail created will be blank. Maybe there's a quick fix for this problem?

 

It doesn't bother me much, but for my clients, they will probably continue to upload images with ampersands in the filenames and complain when the image created is blank.

 

Thanks folks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×