Jump to content
mloeffen

'On The Fly' Auto Thumbnailer using GD Library 2.1

Recommended Posts

I just implemented this contrib, and I like the better image quality, but....

 

Has anyone experienced the same thing? My images (as small as they are) are taking up to two to three seconds to download.

 

You can see the problem, especially in the download of individual product images that are not on the home page: www.aspenlaserstore.com

 

Is there a way to speed things up?

 

Thanks!


osCommerce MS2

SPPC incl. Specials By Category, Prices By Category

Vendors, Easy Populate, UPS XML, USPS Methods

Share this post


Link to post
Share on other sites

this contribution works perfectly, but the image format/url generates errors on html validators, is there a workaround for this?

Share this post


Link to post
Share on other sites
Warning Line 181 column 199: cannot generate system identifier for general entity "w".

 

...=images/image_url.gif&w=99&h=100" width="99" height="100" bord

 

An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs".

 

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters.

 

If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem.

 

Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.

Share this post


Link to post
Share on other sites

I need som help. My last thing to do before going live is to implement auto thumbnailer in admin and in "X-Sell" admin pages. I really want my clients to see the right image sizes in admin. X-Sell's admin page looks awful without.

Share this post


Link to post
Share on other sites

Open the includes\functions\html_output.php Backup first then find this line of code in function tep_image

 

$image = '<img src="product_thumb.php?img='.$src.'&w='.
	tep_output_string($width).'&h='.tep_output_string($height).'"';

 

replace it with:

$image = '<img src="product_thumb.php?img='.$src.'&w='.tep_output_string($width).'&h='.tep_output_string($height).'"';

 

retry with the validator

 

 

I need som help. My last thing to do before going live is to implement auto thumbnailer in admin and in "X-Sell" admin pages. I really want my clients to see the right image sizes in admin. X-Sell's admin page looks awful without.

 

Make sure the x-sell files when they call the tep_image function are passing the width/height parameters with fixed dimensions (and not in %) so the the gd code will take over.

Share this post


Link to post
Share on other sites

Thanks. Hum, both codes above are the same?

 

Are you refering to both html_output, the one in catalog or the one in admin? Suppose its the one in admin.

Edited by Fredrik.r

Share this post


Link to post
Share on other sites
Are you refering to both html_output, the one in catalog or the one in admin? Suppose its the one in admin.

no, I was refering to the question by eww. For your case here is what I mentioned:

 

Make sure the x-sell files when they call the tep_image function are passing the width/height parameters with fixed dimensions (and not in %) so the the gd code will take over.

so check where the x-sell files call the tep_image function. Make sure you have the height/width parameters specified and not some %.

 

unfortunately the forum combined subsequent posts into one although I tried to separate them.

Share this post


Link to post
Share on other sites

Is it possible to use the real thumbnails generated by Auto Thumbnailer in admin/categories.php?

These are the two instances of images in X-Sell;

 

1, This is ok, just shows the big/original picture

 

echo tep_image('../images/'.$products_name['products_image']);

 

 

2, I would like this to show the small or medium thumbnail generated by Auto Thumbnailer;

 

echo ((is_file('../images/'.$products['products_image'])) ? tep_image('../images/'.$products['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) : '<br>'.TEXT_NO_IMAGE.'<br>');

Edited by Fredrik.r

Share this post


Link to post
Share on other sites

I've seen now that Auto Thumbnailer does not work at all in admin, only in the shop. Isn't AT supposed to make thumbnails of all pictures in admin too? I just want it to look nice.

Share this post


Link to post
Share on other sites

can you post the tep_image function you're using? But before that if you have this in the x-sell files on the admin side it should work. (because it specifies the width/height)

 

echo ((is_file('../images/'.$products['products_image'])) ? tep_image('../images/'.$products['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) : '<br>'.TEXT_NO_IMAGE.'<br>');

 

PS: Its the same function code on both catalog & admin sides

Edited by enigma1

Share this post


Link to post
Share on other sites

I'm sorry, I forgot to change define ('DIR_WS_CATALOG_IMAGES', 'images/'); to define('DIR_WS_CATALOG_IMAGES', '../images/'); in admin/includes/configure.php

 

But with or without, X-sell is still using product_thumb.php

It displays the picture wrong in X-Sell but when I open the picture in a new window the path says: /devstore/admin/product_thumb.php?img=../images/Seiko%20SNL015P1%20large.jpg&w=696&h=145

 

And thats without ../images/ in configure.php

 

If I change it to /..images/ in configure.php none of my pictures shows in admin/categories.php

When I open the "picture" in a new window the path says domain.se/images/picture.jpg.

It should be domain.se/devstore/images/picture.jpg so I guess I should NOT use ../images/ in configure.php

 

Categories.php doesn't use Auto Thumbnailer at all.

 

I've checked both html_output, both have the same function code.

Share this post


Link to post
Share on other sites

the admin configure for the images to be accessible should be like

define('DIR_WS_CATALOG_IMAGES', '../images/');

 

so it goes back a dir then accesses the image path. The categories.php uses something like this:

tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

 

the tep_info_image is wrapper that calls the tep_image so the thumbnailer again is in effect. Do you see the images distorted with the admin products preview?

Share this post


Link to post
Share on other sites

Yes they are distorted.

 

But if using ../images/ in configure.php I don't see them at all. That's because /images/ are pointing to domain.se/devstore/images and ../images/ to domain.se/images... And my store is at domain.se/devstore/

 

Therefor I cannot use ../images right? The image path in cofigure.php can't be the problem?

Share this post


Link to post
Share on other sites

why the image path will be a problem? When the code flow reaches the tep_image function the path is determined. The path is totally different issue from the thumbnailer has to do with configuration settings (Unless you have a version that hardcodes the path). But its strange why the images are distorted. The images are jpg right? and you have a product_thumb.php file in the catalog\admin\ directory?

Share this post


Link to post
Share on other sites
why the image path will be a problem? When the code flow reaches the tep_image function the path is determined. The path is totally different issue from the thumbnailer has to do with configuration settings (Unless you have a version that hardcodes the path). But its strange why the images are distorted. The images are jpg right? and you have a product_thumb.php file in the catalog\admin\ directory?

 

Yes thats right.

 

But if I use ../images/ in configure.php osC tries to find my pictures in domain.se/images when the shop is actually at domain.se/devstore/images.

Share this post


Link to post
Share on other sites

// Example //

 

CODE IN PHP-FILES

 

In admin/categories.php;

tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)

 

In x-sell-php;

echo ((is_file('../images/'.$products['products_image'])) ? tep_image('../images/'.$products['products_image'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) : '<br>'.TEXT_NO_IMAGE.'<br>');

 

----------

 

VIEWING SOURCE CODE

 

In admin/categories.php (using the biggest image);

<img src="/devstore/images/CIMG0982.jpg" width="100" height="100"

 

In X-Sell (using the biggest image);

<img src="product_thumb.php?img=../images/Seiko SNL015P1 large.jpg&w=696&h=145" width="696" height="145"

 

 

(As you can see it finds the image without having ../images/ in configure.php but it's still not working)

Edited by Fredrik.r

Share this post


Link to post
Share on other sites

If your admin module is in

domain.se/devstore/admin

 

then the ../images/ will step up a level and enter the images dir of the catalog. But if your admin module is at

domain.se/admin

 

is not going to work.

 

The x-sell should use the DIR_WS_CATALOG_IMAGES definition instead of hard-coding directories.

Now since you have this:

<img src="product_thumb.php?img=../images/Seiko SNL015P1 large.jpg&w=696&h=145" width="696" height="145"

its obvious the gd thumbnailer didn't do anything. I think the reason is it couldn't find the image path?

Share this post


Link to post
Share on other sites

my admin is at devstore/admin.

 

The images shows in admin with just /images. When changing to ../images/ the categories images (which do not use product_thumb.php for some reason!?) doesnt show and there's no difference from above in the X-Sell admin page.

Edited by Fredrik.r

Share this post


Link to post
Share on other sites

Ok a couple of things:

 

1. In your admin\categories.php make sure you have this line (near the end of the file)

$contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_image);

 

2. In your admin\includes\functions\general.php make sure you have this function

  function tep_info_image($image, $alt, $width = '', $height = '') {
if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
  $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
} else {
  $image = TEXT_IMAGE_NONEXISTENT;
}

return $image;
 }

 

3. In your admin\includes\configure.php make sure you have these definition also

define('DIR_FS_CATALOG', 'full path here'); // absolute path required
define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');
define('DIR_WS_CATALOG_IMAGES', '../images/');

 

the DIR_FS defs must be set correctly or the image functions will fail (as you can see from the code they may not be able to find the image file)

Share this post


Link to post
Share on other sites
As for your problem: it should work, but only since version 2.0 an aditional thumbnail-directory is supported. If you use version 2.1.2 the completely rewritten readme shows two sites where the contribution works for, and at least one store is located within root. This readme is also easier to follow when installing than the readme.txt that was included. Why not use that one?

 

Use the newer contribution-version and give me a link to your site (PM me if you want) and I'll help you out.

Hi,

i'm using the 2.1.2 version but i have this problem...because of my catalog is in the root directory, the images don't show.. :(

Share this post


Link to post
Share on other sites

hi, i can use this contribution correctly, but just wonder is it possible that the thumbnail size can be the size i set on admin-->configuare-->image-->small image size?

my shop will look awful with some thumbnail that are short than others. coz my original images are all in different sizes.

is it possible to have the thumbnail stretch to the small image size i set at admin??

 

thank you

Share this post


Link to post
Share on other sites
Hi,

i'm using the 2.1.2 version but i have this problem...because of my catalog is in the root directory, the images don't show.. :(

Anibody can help me?

I noticed this strange behavoiur:

 

The thumbs are saved correctly, but in the product_thumb.php file:

// Output the image:
if ($image[2] == 2 || ($image[2] == 1 && $gif_as_jpeg))
{
if ($tn_server_cache)
{
	$thumbnail = modify_tn_path($_GET['img'].'.thumb_'.$_GET['w'].'x'.$_GET['h'].'.jpg');
	imagejpeg($tmp_img,$thumbnail, 100);
	//http_headers($thumbnail);
	http_headers($_GET['img']); [b]<----- I HAVE TO ADD THIS CODE TO MAKE IT WORK[/b]

See above the new code...

 

Cause if a let "http_headers($thumbnail);" code, the images aren't shown... :(

Edited by Giacomo79

Share this post


Link to post
Share on other sites

I am still unable to make this contribution works. The thumbnail is not generated (broken link image), though the URL seems to be correct (points to product_thumb.php)

 

- osCommerce 2.2-MS2

- My hosting company uses PHP 4.3.10 (Zend: 1.3.0) (GD: 1.3.0) -> checked by php_info()

- I have done exactly the steps in the installation doc

- product_thumb.php is in root directory

- I don't use thumbnails directory for $tn_path, use '' instead, set images directory permission to 777

- GIF generation is not allowed, therefore because of the problem all osC default icons in GIF are broken

- Some parameters in product_thumb.php like $use_resampling and $use_truecolor have been set to false

- Images size settings in Admin have been set correctly

 

Any help would be appreciated as my store will be launched within few days. Otherwise, I'll be back to have 2 pictures-set for each product.

 

PS: I tried also 'otf thumbnailer with multiple thumbnail sizes' contribution earlier, it doesn't work either. Same problem, the thumbnail is not generated.

Edited by xty

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

×