Jump to content
Rickharris

'On the Fly' Auto Thumbnailer using GD Library

Recommended Posts

On the fly does nothing more than make your Thumbnail images look like they are in proportion, and very small in file size. A full size jpg that has a file size of say 65kb is thumbed out around 3kb. or even less. They retain quality and load fast.

 

I myself like the way "on the fly cuts down on load time and still gives great thumbnails.

 

Kel


I live in my own little world. But it's OK. They know me here.

Share this post


Link to post
Share on other sites
I changed my configuration from:

/shop/images/ to images/

/shop/icons/ to icons/

 

That fixed my problem using your original configuration. Thanks for the great contribution!

Did'ya here that - everyone who's having problems with this contrib? Check your image paths in the config ;)


** 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 have this great contrib working fine for 70% of my images but some are not showing I have verified they are in the sql and via ftp in images folder but no show, but I have noticed when I click on the images to check path the image name is half the size it should be.

 

ie I have image 12345678910111213.jpg this does not show is this something to do maybe with image name length?

 

Any help gratefull thx in advance.


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites

What is the file extention of the images that are not showing?

 

If they are .gif then your server needs to update it's GD to the latest version. How about paste in the real file name including it's extention and maybe we can figure out why.

 

Kel


I live in my own little world. But it's OK. They know me here.

Share this post


Link to post
Share on other sites

Hi, for me about 90% of the images are properly thumbnailed. However, there are some that just won't show. I've tried everything. Images are not corrupt. All my paths are correct. When I look at the source code of the product_info.php page everything looks fine. The thumb should be visible, the html for it is there. But it doesn't show. If I take the thumb's URL from the source and paste it into the browser the thumbnailed image shows up just fine. I'm going crazy! What could it be? :blink:

Share this post


Link to post
Share on other sites

Can't really tell ya much without seeing it, but my guess is that there are certain image formats your version of GD wasn't complied to support(?)


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

Share this post


Link to post
Share on other sites

This is weird, have this site http://www.scrapscape.com/newshop/ and some of the images are showing using the thumbnailer and some dont I have checked all images and all are .jpg as required but some work and some dont.

 

I assume this is correct when I right click any .jpg image for image properties - product_thumb.php?img=images/all_boy_buttons.jpg&w=100&h=99

 

But I get images/bar_links.jpg on some of the images which isnt using the thumbnailer and the image is bad quality as a result, this is happening with a great amount of the images what is going wrong here?

 

Any ideas, I dont seem to be isolated in this problem.


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites
Just added this If statement at the top of the function to replace the two individual lines as listed in the previous post:

 

if (substr($src, 0, 9) == '/catalog/') { ? ? // replace "catalog" with your root osc directory name
? $src = substr($src, 9);
? }

 

Nate, I don't know if you would want to add this to the source or not?

 

- Drew

Thx to Drews fix my problem is sorted, as before great contrib, just needed a minor fix to work for me thx Drew. ;)


Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites

Ha! well nate, you got me thinking again after I had given up and bam - I figured it out. It was that darn old "apostrophe/single quote" problem. When the title has an apostrophe in it the thumb doesn't show up, even though it was clearly in the html. Weird, can't explain it, but that's what was happening. btw, I've got the Cool Menu contribution installed as well, dunno if that has something to do with it.

Anyway, much thanks. These forums are invaluabe! Hopefully this will help others.

Fabulous contribution, thanks!

Edited by ciraklizer

Share this post


Link to post
Share on other sites

i made a little change on product_thumb.php in order to save the rescaled picture after the first request.

 

for example if the picture is named: test.jpg at the first request of a thumbnailed version of that picture it will create the test.jpg.thumb.jpg (i like dots ! ^_^) on any subsequent requests product_thumb.php won't rescale it again but it will simply send the already scaled file.

 

if you change the original picture you need to delete manually the thumbnailed version.

 

http://www.oscommerce.com/community/contributions,2226

 

hope to help.

comments welcome.

Share this post


Link to post
Share on other sites

Saving the rescaled thumbs seems to be working just great for me. Anyone else?

 

BTW, Thanks for the contribution!

 

Dennis

Share this post


Link to post
Share on other sites

I have a problem with the script. I have spent all evening searching the forums and reading then re-reding the thread. I can't seem to find anything that my be able to fix my problem..

 

The script seems to work fine but the guy i did the website for has just uploaded an image and it the thumbnail is white. The path looks fine, i just can't figure why its doing it..

 

Here is a link to the page in question..

 

http://www.meinhost.net/HeadTurning/produc...?products_id=52

 

I am puxxled with this one, i have tried to upload a number of image files from my machine and i am not hitting problems unless i save the image he uploaded and upload that one.

 

I have tested this on two seperate servers and i get the EXACT same problem. As you can see GD is working to some extent i guess its hitting a problem somewhere with the formatting of the image..

 

Subsequently if i open the jpg in photoshop and save it for web under a different name the image works fine.

 

Hopefullyy we can sort this some way or another.

 

Kindest Regards

 

Tim

Share this post


Link to post
Share on other sites

I continually have these error messages in my server's error log:

 

[sat Aug 28 09:40:23 2004] [error] [client 209.337.239.174] File does not exist: /usr/home/myname/public_html/catalog/images/mint/rare/3126.jpg&w=90&h=111

 

After installing the add on:

http://www.oscommerce.com/community/contributions,2226

 

That is the addition to the "'On the Fly' Auto Thumbnailer using GD Library" that creates the thumb in the images folder for future use.

 

Does that mean the already thumb is not being accessed?

 

I am confused! Cam anyone explain?

 

Dennis

Share this post


Link to post
Share on other sites
I changed my configuration from:

/shop/images/ to images/

/shop/icons/ to icons/

 

That fixed my problem using your original configuration. Thanks for the great contribution!

Did'ya here that - everyone who's having problems with this contrib? Check your image paths in the config ;)

Right on! That did it for me too. I was having the same problem and spent hours reading this thread and trying to implement the changes suggested.

 

Just as a little feedback for others having the same problem, here's what the changes in my includes/configure.php look like now:

 

define('DIR_WS_HTTP_CATALOG', '/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/catalog/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', 'icons/');

 

Note that the first two have the "/" before the store name. I made the mistake to take it off and got a big error! :lol:

 

And another thing to remember is to chmod this file to 400.

 

An idea for this problem is that it might be caused by OSC being installed from cPanel. Could that be it? Can someone else having the same problem confirm it?

 

Phew! I'm so glad I've got this working now! Thank you so much, nate, for a great contribution (that should be implemented to the original program IMO) and to everybody who contributed somehow. ^_^

Edited by Patty

Patty

Share this post


Link to post
Share on other sites
The script seems to work fine but the guy i did the website for has just uploaded an image and it the thumbnail is white.

That's a bit odd. The only thing I might suggest is that there's something different about the way he's saving his JPG files - perhaps a format with a JPG thumbnail header or "progressive" JPG, which the GD library is having difficulty processing.

 

I continually have these error messages in my server's error log... That is the addition to the "'On the Fly' Auto Thumbnailer using GD Library" that creates the thumb in the images folder for future use.

I don't sanction or support that hack to my contrib, so you might want to PM the author about that...

 

An idea for this problem is that it might be caused by OSC being installed from cPanel. Could that be it? Can someone else having the same problem confirm it?

I can't confirm that, but I'm guessing a CP install of oSC is likely not as tight as it ought to be... At any rate, the lack of a properly specified path is generally the root of most problems (few that there are) with this contrib.


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

Share this post


Link to post
Share on other sites

Nate, i think i'll just tell him to use a different piece of software to resize the images!

 

Thanks alot for the help fella :)

Share this post


Link to post
Share on other sites

Hi Guys,

 

I just installed this contrib and it works great!

 

Only problem is that 99% or my thumbnails are Gifs which won't work. All I get is an error saying

FireFox: The image cannot be displayed because it contains errors.

IE6: Call to undefined function imagecreatefromgif();

 

Any one have any ideas how to fix this?

 

Im running Debian 3.0 2.6.7

Apache 1.3.31

>GD2

Copy from the PHP Info:

gd

GD Support enabled

GD Version 2.0 or higher

FreeType Support enabled

FreeType Linkage with freetype

T1Lib Support enabled

JPG Support enabled

PNG Support enabled

WBMP Support enabled

 

I can't think of anything else... any suggestions greatly appreciated!

 

Garreth.

Share this post


Link to post
Share on other sites
Nate, i think i'll just tell him to use a different piece of software to resize the images!

Cool - you could have him just try and upload a random image off the web as a product image, just to troubleshoot, but I get the feeling he's using some oddball image editing software whose fle output GD can't handle correctly...

 

Only problem is that 99% or my thumbnails are Gifs which won't work.

Hi - looking closely at your GD info, it seem that your GD library wasn't even complied with GIF read support, which is unusual. GD < 2.0 generally has gif read/write support where > 2.0 has gif read support, but not gif write support (due to liscencing issued)...

 

This mod requires at least GIF read support, so it can read your GIF product images (not *thumbnails*) , which are then output as JPGs. Your options are to either recompile your GD library to support GIF read or switch to using JPGs or PNGs for product and other thumbnailed images...


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

Share this post


Link to post
Share on other sites

Sorry but after reading all 15 pages

I still havent found a solution to my problem. Or just read over it.

 

On my "products display" I get the red X box(s)

Red X/No Image box sized

Its obviously calling the MOD as I dont have a thumbnail or a size set (set as 0 in config) .

When I view a product page there is no thumbnail box or ENLARGE link whatsoever.

http://sk8.worldconspiracy.org/index.php?cPath=97_116

Even though I do have a full size image listed in the Admin.

Tested without MOD and works fine. No thumbnail (as should be) and ENLARGE link there and it works.

 

Ideas?

Share this post


Link to post
Share on other sites

I don't see any red X's... It appears as though no product images have been uploaded yet...

 

You can verify that the thumbnail portion is working below:

 

http://sk8.worldconspiracy.org/product_thu...gif&w=200&h=200

 

So it's likely a problem with your image paths in your config or that you didn't paste in the html_output code properly...


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

Share this post


Link to post
Share on other sites

Sorry , still trouble shooting this.

Had switched back to defualt Output file for a few seconds. MOD one is back in now.

I had tested before with

thumb nail

Worked fine. Why I was stumped.

 

Even though I have double checked this here is my html_output.php file:

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

}CODE]

 

My config file is correct as everything works

without the MOD. I had checked that becasue of earlier post.

Share this post


Link to post
Share on other sites
My config file is correct as everything works without the MOD. I had checked that becasue of earlier post.

I appreciate you checking the other posts, but that logic is not valid, unfortunately.

 

Check your configure.php again and make sure the lines in it read (based on your website):

define('DIR_WS_HTTP_CATALOG', '/');
define('DIR_WS_HTTPS_CATALOG', '/');
define('DIR_WS_IMAGES', 'images/');


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

Share this post


Link to post
Share on other sites

Sorry my logic was off but I had checked it.

I just rechecked it. Checked both just for sure.

 

Anything else I should look at?

Share this post


Link to post
Share on other sites

As a side note:

If I place the "product_thumb.php" file anywhere else, IE: /templates/content/product_thumb.php

Click Here To See

I get the following error:

 

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/flipc/sk8.worldconspiracy.org/html/templates/content/product_thumb.php on line 27

Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/flipc/sk8.worldconspiracy.org/html/templates/content/product_thumb.php on line 35

 

This dosent make much sense since it works correctly from main directory.

Working in Main

Share this post


Link to post
Share on other sites

Actually, it makes perfect sense since the image reference passed to product_thumb.php is relative...

 

Don't know what else you should look at, but you are saying your config matches what I have above?


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

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

×