Jump to content
Sign in to follow this  
woomis

Automatic Thumbnails Contrib 1484

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?

Share this post


Link to post
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;
}
?>

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Are you sure that is the complete code? Normally you'd use this function to specify the image quality:

 

imagejpeg ($dstim , $dst , JPEGQUALITY);

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I have a question about this contrib also.

 

Where are the the thumbnail images stored?

 

How can one verify it is working?


Rik Rasmussen

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

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
Sign in to follow this  

×