Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

'On The Fly' Auto Thumbnailer using GD Library 2.1


mloeffen

Recommended Posts

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)

 

Thank you. I have checked the three things above and they are there. I will check all install instructions (again).. I'll get back if I can't manage to solve it.

Link to comment
Share on other sites

  • Replies 556
  • Created
  • Last Reply

Top Posters In This Topic

I noticed that "my" file_exists function doesn't work if in the filename there is a dot (Like "name.php.thumb.jpg")

 

Anybody else noticed this problem?

Errata corrige: i noticed that files created with this contribution don't come seen from "file_exists" function. If i create a file in the same directory, the file_exists function works... :(

 

Somebody can explain this pls?

Link to comment
Share on other sites

Ok there is this for the image path in the catalog\admin\product_thumb.php

 

// If you are required to set the full path for file_exists(), set this:

// $filename = '/your/path/to/catalog/'.$filename;

 

What is the $filename variable set in each of the cases that doesn't work? Or its still commented out?

Edited by enigma1
Link to comment
Share on other sites

Ok there is this for the image path in the catalog\admin\product_thumb.php

 

// If you are required to set the full path for file_exists(), set this:

// $filename = '/your/path/to/catalog/'.$filename;

 

What is the $filename variable set in each of the cases that doesn't work? Or its still commented out?

I saw it, and it doesn't work anyway... :(

I guess it's a bug of "file_exists" php function, i'm looking for it on web and this function are other problems

Link to comment
Share on other sites

I saw it, and it doesn't work anyway... :(

I guess it's a bug of "file_exists" php function, i'm looking for it on web and this function are other problems

 

 

Parse error: parse error, unexpected '}' in /home/addictiv/public_html/catalog/includes/functions/html_output.php on line 192

 

Why do I keep getting a parse error, does OTF work with BTS?

Link to comment
Share on other sites

Parse error: parse error, unexpected '}' in /home/addictiv/public_html/catalog/includes/functions/html_output.php on line 192

 

Why do I keep getting a parse error, does OTF work with BTS?

 

Anyone? This is very annoying, it only happens when i go to includes/functions/html_output.php and change

 

  function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  return false;
}

 

TO

 

// "On the Fly" Auto Thumbnailer using GD Library, servercaching and browsercaching
// 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;	
 }

 // Dont calculate if a pixel image is being passed (hope you dont have pixels for sale)
 if (!strstr($image, 'pixel')) {
$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

Im having an issue with This contrib, Acctualy I think I have V.1 installed. I will double check, but...

 

Iv got it installed, and I have GDlib installed and running. How ever i am not getting the thumbnails to show. I keep getting the broken image links popping up instead. Its kinda making me mad. Iv worked on this site for like over a year, spending long hours modding code, and adding in contribs. If any one can help me please do.

 

Im running MS2 with STS if that helps out at all.

Link to comment
Share on other sites

The same thing is happening to me except many of the pictures do work but some other pictures don't show up (have an X) but when I "click to enlarge", the pictures work.

 

Thanks in advance for any help that you can provide!

 

Regards,

Sydney

 

 

 

I wonder if it's a bitmap versus JPEG thing?

 

Regards,

 

Sydney

Link to comment
Share on other sites

To those who have their "catalog" installed in the root . . . that is, your product_thumb.php file is in the root directory.

 

If you get a "not found link" (x's) to the thumbnail image, check your path in your product_thumb.php file, ~ line 40.

 

My "thumbnails" directory is in the root, off my domain name. I changed line 40 from

 

$tn_path = 'thumbnails/'; // The default is 'thumbnails/', should be chmod 777

 

to

 

$tn_path = '../thumbnails/'; // The default is 'thumbnails/', should be chmod 777

 

Hope this helps.

Cheers :)

Edited by Bali Hai
Link to comment
Share on other sites

Hi

I am developing our shop on a live basis, all is good so far but I cannot get this contribution to work, I get the dreaded red X, no files appear to be generated in the thumbnails folder. All works well in our oscommerce setup so I think my configure file is OK. Our server is OK with the GD setup in server info.

 

Please someone help we are ready to go live

Link to comment
Share on other sites

Hi Guys,

 

Been using this contrib for the past 10 months or so and one problem that I have just learned to live with is that for some reason some of the images that are thumbnailed have no color whatsoever which makes them very difficult to see and puts people off. I've eventually got round to trying to sort this out. When you click on the thumbnail the image is fine. I am trying to determine whether this is a GD library issue or a contrib issue. Anyone else come across this before ?

Link to comment
Share on other sites

Just installed. WOW! So awesome.

 

I did have a problem though. in my html_output.php file, there was an error where at the end, there was an extra "}". I got worried real quick and thought, damn, another crappy contrib that isn't yet ready... But then i deleted the "}" and everything is ok, code logic is fine now.

 

I have not tried to use it in admin, I dont think i will, it doesnt matter that much.

And I am going to try some of the Bonus Tips right now.

 

Thanks for the awesome work you guys. This is really really professional for a site to have this.

 

One note: it would be nice if once a thumnail is generated, when it was called by a page, it would have the file location be from the thumbnail directory, not product_thump.php......

 

Thanks again,

Chris

Link to comment
Share on other sites

OOPS, I lied. LOL. There is a problem.

 

GD Image Library seems to be removing whitespace from my images.

I have all of my images of size 640x480. And if i have a product image that isnt that large, i just paste it onto a 640x480 canvas and save it with white space around the actual image. What seems to be happening is that the images have most of the whitespace cut off of them, and then they are resized to 640x480. This causes the images to be of poor quality, showing a lot of jpeg artifacts. It is basically zoomed in. Maybe GD image library is a little too smart....

 

Can I turn this 'function' off somehow??

 

Chris :lol:

Link to comment
Share on other sites

Hi! I installed the great contribution n everything works fine except for using different explorers. It works perfectly in FireFox but a little bit problem when using IE. In IE when click the thumbnails it does display the actuall pixel image but without the scroll bar even the image is bigger than the screen. Any idea please?

you may try to access the link by yourself by clicking the right handside image. Many thanks!

Edited by jwen
Link to comment
Share on other sites

Hi! I installed the great contribution n everything works fine except for using different explorers. It works perfectly in FireFox but a little bit problem when using IE. In IE when click the thumbnails it does display the actuall pixel image but without the scroll bar even the image is bigger than the screen. Any idea please?

you may try to access the link by yourself by clicking the right handside image. Many thanks!

 

Jwen, this is going to take some playing around with numbers, but in popup_image.php, there is a javascript that resizes the page when the image page loads. look below for the code:

 

function resize() {
 if ((navigator.appName == 'Mozilla') || (navigator.appName == 'Netscape')) i=8;
 if (document.images[0]) window.resizeTo(document.images[0].width+15,	document.images[0].height+96-i);
 self.focus();
}

 

Basically, play around with the numbers in IE first. Get it to look good with IE by changing the height to a higher number. see mine is 96.

Then, once IE looks good, you can set it up to resize correctly in Firefox by changing the "i" variable. Mine is set to 8, play with yours.

 

So, since you will be changing the script so that the height is larger, you will have to change the "i" variable to a greater number as well, since it is subtracted fromt he total height.

 

Also, may i recommend making your product images smaller? My screen resolution is 1280x1024 and the pic took up my whole page. for my store, i use 640x480 size pics, this is a good size... Or simply let the autothumbnailer do the work by setting a width and height specification in your image definition. I would show you how, but my code is completely different than the stock page because I have additional contribs installed.

 

See how mine works here

 

Chris

Link to comment
Share on other sites

What a fantastic layout! I love the way u display your images!! If u dont mind can u show me which contribution do that thing or i have to do it manually please?

 

Basically, play around with the numbers in IE first. Get it to look good with IE by changing the height to a higher number. see mine is 96.

Then, once IE looks good, you can set it up to resize correctly in Firefox by changing the "i" variable. Mine is set to 8, play with yours.

 

Thanks Chris! I tried with different number but nothing seems change. I think the 'over size' image produces the problem.

 

Also, may i recommend making your product images smaller? My screen resolution is 1280x1024 and the pic took up my whole page. for my store, i use 640x480 size pics, this is a good size... Or simply let the autothumbnailer do the work by setting a width and height specification in your image definition. I would show you how, but my code is completely different than the stock page because I have additional contribs installed.

Thanks for your recommendation. My store currently beening tested only. I will resize all my images after its open. I just trying to find out a solution whether the problem can be fixed. Then sometimes we need to display really large images it will do the job. But I do appreciate your images layout! :thumbsup:

Edited by jwen
Link to comment
Share on other sites

Hi,

 

I've just installed this contribution and it seems to work great - I have a small problem with where it's storing the thubs - I can only get it to work if I change the "thumbnails" to "" in the configuration. I assume I have to fix something in a path somewhere.

 

What I'd really like to know is if this contribution also has the option of using the watermark?

 

Honestly - I've looked and I've found a lot of people mentioning it but no useful information. I think this is a great contribution - but the support threads are a kind of a nightmare with 3 offshoots of the orig contribution. If someone could point me in the right direction I would appreciate it. I'm sorry for posting if It's obvious and I've overlooked it.

 

Thank you,

Dan

Link to comment
Share on other sites

What a fantastic layout! I love the way u display your images!! If u dont mind can u show me which contribution do that thing or i have to do it manually please?

 

I used more pics 6 - http://www.oscommerce.com/community/contributions,1611

you will have to play around with the popup_image.php file code to organize it the way you desire.

 

Thanks Chris! I tried with different number but nothing seems change. I think the 'over size' image produces the problem.

Thanks for your recommendation. My store currently beening tested only. I will resize all my images after its open. I just trying to find out a solution whether the problem can be fixed. Then sometimes we need to display really large images it will do the job. But I do appreciate your images layout! :thumbsup:

 

It probably is your oversized images. The code may be being over-ridden by the browser since your images cause the popup_image page to display larger than your screen allows. Try resizing your image, this should fix the problem... Thanks for the compliment. Good day.

B)

Chris

Link to comment
Share on other sites

Hi,

 

thanks for this contribution. But it unfortunately doesn't work with my shop!

 

There are no images shown...I simply followed the installation manual, added the product_thumb.php to my catalog dir and changed the tep_image function. I did not add a product_thumb.php to the admin dir, but it should work without one, too, right?

 

The /catalog/images/thumbnails dir is empty! What can i do now?

 

I use BTS! May this be the problem's reason?

Link to comment
Share on other sites

I installed this mod on a couple of sites and it works great. The only thing that bothers me is the images that are auto generated are very poor quality, they look very pixelated and not nearly as clear as the original larger image. Does anyone know how to fix this? Is it something to do with GD or the contribution? You can see what I mean about the quality issue if you look at my website.

 

http://www.mediaessence.com/shop/accessori...ts-c-22_23.html

Link to comment
Share on other sites

Hi,

 

thanks for this contribution. But it unfortunately doesn't work with my shop!

 

There are no images shown...I simply followed the installation manual, added the product_thumb.php to my catalog dir and changed the tep_image function. I did not add a product_thumb.php to the admin dir, but it should work without one, too, right?

 

The /catalog/images/thumbnails dir is empty! What can i do now?

 

I use BTS! May this be the problem's reason?

 

I want to describe my problem more exactly:

 

- I use PHP5

- I use BTS 1.5

- I use OsCommerce in the newest version

 

The image's path is like this one: http://localhost/jm-versand/catalog/produc...jpg&w=111&h=120

 

man3itu.jpg is the name of the image I chose when creating the product. It is saved under http://localhost/jm-versand/catalog/images/man3itu.jpg ... But I've created a thumbnails directory.

 

If I enter http://localhost/jm-versand/catalog/produc...jpg&w=111&h=120 to Firefox address line the following message is shown: imagejpeg(): Unable to open 'thumbnails/images/man3itu.jpg.thumb_111x120.jpg' for writing in C:\apachefriends\xampp\htdocs\jm-versand\catalog\product_thumb.php on line 332

 

My configure.php looks like this:

<?php
/*
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// Define the webserver and path parameters
// * DIR_FS_* = Filesystem directories (local/physical)
// * DIR_WS_* = Webserver directories (virtual/URL)
 define('HTTP_SERVER', 'http://localhost/jm-versand'); // eg, http://localhost - should not be empty for productive servers
 define('HTTPS_SERVER', ''); // eg, https://localhost - should not be empty for productive servers
 define('ENABLE_SSL', false); // secure webserver for checkout procedure?
 define('HTTP_COOKIE_DOMAIN', 'localhost');
 define('HTTPS_COOKIE_DOMAIN', '');
 define('HTTP_COOKIE_PATH', '/jm-versand/catalog/');
 define('HTTPS_COOKIE_PATH', '');
 define('DIR_WS_HTTP_CATALOG', '/catalog/');
 define('DIR_WS_HTTPS_CATALOG', '/catalog/');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', 'C:/apachefriends/xampp/htdocs/jm-versand/catalog/');
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

// define our database connection
 define('DB_SERVER', 'localhost'); // eg, localhost - should not be empty for productive servers
 define('DB_SERVER_USERNAME', 'root');
 define('DB_SERVER_PASSWORD', '');
 define('DB_DATABASE', 'zugu');
 define('USE_PCONNECT', 'false'); // use persistent connections?
 define('STORE_SESSIONS', 'mysql'); // leave empty '' for default handler or set to 'mysql'
?>

 

 

Please help me and let me know what more information you need! I'm working on this problem for days.

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...