Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Automatic Thumbnails Contrib 1484


woomis

Recommended Posts

I'm working with the Automatic Thumbnail contribution found at http://www.oscommerce.com/community/contributions,1484. I've noticed that the thumbnails generated are in truecolor and are resampled to about 1/15th of the original size of the image. My resulting thumbnails are around 2.5kb.

 

My question is: How can I increase the output quality of the jpegs in this contrib? I would like the resulting thumbnails to be about 6kb. Can someone give me a clue as to what portion in html_output.php I need to edit in order to achieve this?

Link to comment
Share on other sites

The answer lies somewhere in here...

 

if (!isset ($x)) $x = floor ($y * $imagedata[0] / $imagedata[1]);


    if (!isset ($y)) $y = floor ($x * $imagedata[1] / $imagedata[0]);

    if ($aspectratio && isset ($x) && isset ($y)) {
 if ((($imagedata[1]/$y) > ($imagedata[0]/$x) )){
   $x=ceil(($imagedata[0]/$imagedata[1])* $y);
 } else {
   $y=ceil($x/($imagedata[0]/$imagedata[1]));
 }
    }

    $thumbfile =  '/' . basename($image);
    if (file_exists ($cachedir.$thumbfile)) {
         $thumbdata = getimagesize ($cachedir.$thumbfile);
         $thumbdata[0] == $x && $thumbdata[1] == $y
              ? $iscached = true
              : $iscached = false;
    } else {
         $iscached = false;
    }

    if (!$iscached) {
         ($imagedata[0] > $x || $imagedata[1] > $y) || (($imagedata[0] < $x || $imagedata[1] < $y) && $resize)
              ? $makethumb = true
              : $makethumb = false;
    } else {
         $makethumb = false;
    }
    if ($makethumb) {
         $image = call_user_func("imagecreatefrom".$types[$imagedata[2]], $image);
         $thumb = imagecreatetruecolor ($x, $y);
	 imagecopyresampled ($thumb, $image, 0, 0, 0, 0, $x, $y, $imagedata[0], $imagedata[1]);
         call_user_func("image".$types[$imagedata[2]], $thumb, $cachedir.$thumbfile);
         imagedestroy ($image);
         imagedestroy ($thumb);
         $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile;
    } else {
         $iscached
              ? $image = DIR_WS_IMAGES . 'imagecache' . $thumbfile
              : $image = substr ($image, (strrpos (DIR_FS_CATALOG . '/', '/'))+1);
    }
return $image;
}
?>

Link to comment
Share on other sites

  • 1 month later...
I'm working with the Automatic Thumbnail contribution found at http://www.oscommerce.com/community/contributions,1484.  I've noticed that the thumbnails generated are in truecolor and are resampled to about 1/15th of the original size of the image.  My resulting thumbnails are around 2.5kb. 

 

My question is: How can I increase the output quality of the jpegs in this contrib? I would like the resulting thumbnails to be about 6kb.  Can someone give me a clue as to what portion in html_output.php I need to edit in order to achieve this?

 

Just wondering if found a solution?

 

Cheers

Nicole

Link to comment
Share on other sites

Problem is you can't specify 'quality' with imagecopyresample, and he outputs just the same type as came in, so cannot be sure if it is jpeg (and then use quality factor to save).

 

Just wait for the new one... ;-) [or be sure it's ALL jpegs and then do like radders said]

I don't want to set the world on fire—I just want to start a flame in your heart.

 

osCommerce Contributions:

Class cc_show() v1.0 – Show Credit Cards, Gateways

More Product Weight v1.0

Link to comment
Share on other sites

  • 3 weeks later...

I installed the files included in the contrib download rather than edit since I had a very fresh install of Milestone 2.

 

However, I can find no directory containing thumbnails.

 

Also, prior to the contrib install, when I uploaded an image for a product, it was saved in the product manufacturers directory inside the images directory. Now, all the uploaded images are going into the images directory.

 

Is this the best place to discuss this contrib?

Rik Rasmussen

Link to comment
Share on other sites

The contrib download includes what appears to be two versions of html_ouput.php to go into the catalog/includes/functions folder.

 

one is html_output.php, the other is html_output_CVS-MS3.php

 

Which of these should be used with Milestone2?

Rik Rasmussen

Link to comment
Share on other sites

It does not seem to me that adding this contrib has actually changed anything.

 

When I view my store I do get small images, but if I right click on the small image, the path is to the big image I uploaded, the file size is that of the big image. The size of the image is small as I have it set in admin, but it does not appear to be a thumbnail. It appears that it is sending the browser the full image and just displaying it smaller.

 

I have looked the the code in the files in my catalog folders to be sure the radder ctrib code is there and it is.

 

What else do I need to do to get the creation of thumbnails to work.

Rik Rasmussen

Link to comment
Share on other sites

Even though I was working on the wrong contrib here, just in case anyone sees this and wonders, I did get my problem solved. I had to enter a value for the small image width and height in Admin. I was only using the width.

 

Once I did this, Automatic Thumbnail Creator v1.0 works perfect.

Rik Rasmussen

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