Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

'On the Fly' Auto Thumbnailer using GD Library


Guest

Recommended Posts

Nate,

 

Great update to your wonderful OTF mod I already installed a couple months ago. I haven't installed this one yet, but i'm sure it'll work fine.

 

Yeah it would be nice for it to save the image in a cache directory with a filename such as "imagename_small.jpg" or something like that.

 

Here's my thoughts on that:

 

I was actually going to attempt to modify your contribution to search the manufacturer directory (I have a folder for each manufacturer, an image subfolder, and soon to be a thumbnail subfolder) for the desired image in the thumbnail subfolder. If it does exist then it'll load that image unmodifed as it is already resized manually (Photoshop resizes a little cleaner and small filesized than the GD Library). If the thumbnail image does not exist then it'll check the image cache folder for the thumbnail. If no image cache thumbnail is found, one will be created.

 

I don't think everyone is going to want to manually create multiple sized thumbnails, but i'm obsessive compulsive so I don't mind :rolleyes: . But it still gives the flexibility whether I do it for everything or just some products.

 

My only concern is whether check to see if a file exist takes extra unnecessary resources. I'm sure the one check to see if the cached image exists is going to be A LOT faster than command GD to create a new one everytime.

 

Well i'm going to attempt this pretty soon as my estimated download times are in the upper mid range compared to my competitors :( .

 

Once again...another great contribution Nate. Thanks.

I ♥ PHP/MYSQL/CSS

Link to comment
Share on other sites

  • Replies 313
  • Created
  • Last Reply

Top Posters In This Topic

CP Farhood, see this thread for a possible solution to your problem...

 

http://www.oscommerce.com/forums/index.php?sho...=0entry416679

 

I plan to rollout a slightly updated contrib with that fix and other suggested additions soon...

 

joker, do a right click on the image to see if it is being referred to as simply imagename.jpg or product_thumb.php?img=blahblah... (Should be the latter)

 

Check out page 6, 7th post down of this thread... see if you are getting the proper ratio scale but not the thumbnailed (decreased file size) images... My only thought is that the dont_calculate is somehow being set to 1, but I'm still at a loss how one portion of it could work and the other not, if you have the GD library installed... Thy some echoing and troubleshooting in that area and lemme know if anything weird turns up...

 

Paulie, sorry I have no knowledge if anyone is running on Win2K server, though joker may or may not be having the same problem (scaled images but not shrunken filesize)...

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

Link to comment
Share on other sites

Hi

 

Installed this mod and all works great, the best mod for images i have tried, and i've tried them all!!!

The only problem i have is that in admin the images seem to be distorted to the size i have put in admin configuration/images, although this doesn't extend through to the catalog and as i have said they show perfectly.

 

However i have just installed PDF_Catalogs_v1.51 which is obviously pulling the images from the admin, so it is showing all the images distorted.

 

You can view what i mean here http://www.spicybids.co.uk/shop/pdf_catalogue_info.php (WARNING: Adult site)

 

Has anyone overcome this or know how i can overcome it!!

 

Cheers Richard

Link to comment
Share on other sites

I haven't tried it, but you could likely repeat the installation for the admin portion of your catalog... i.e. drop a copy of product_thumb.php in your /admin directory and replace your *admins* includes/functions/html_output.php tep_image function to provide the same functionality as the catalog thumbnailing....

 

P.S. I should have a New Version coming out soon which supports *transparencies* and does checks to your system to see if your GD setup can read/export various file types and adjusts output accordingly (should provide compatability with older versions of the GD lib (1.6-1.8, etc...)

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

Link to comment
Share on other sites

P.S. I should have a New Version coming out soon which supports *transparencies* and does checks to your system to see if your GD setup can read/export various file types and adjusts output accordingly (should provide compatability with older versions of the GD lib (1.6-1.8, etc...)

That would be awesome. My webhost backwards updated to an older GD version and now this contrib doens't work anymore.

 

...........waiting.............patiently.................

Link to comment
Share on other sites

What version, incidentally?.. If it's 1.6 or older you wont be able to use transparent PNGs... If it's 1.6 *exactly* no GIF support whatsoever.. But if it's 1.8 or something like that, you should be in the clear - although transparent graphics will be output as PNGs as there's no GIF output after 1.6 (liscencing issues)...

 

Like I said, I'm gonna make use of the gd_info function and have it determine automatically what the individual's setup is...

 

If you wanna be an older GD lib guinnea pig, PM me your email and I'll send an advance release!

 

Still testing - might have something as early as tonite (GMT -5) or tomoorrah!

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

Link to comment
Share on other sites

Hi Spiceworld, you sure? What do you mean by "it wouldn't work"... No change? No images? When you right-click the image is product_thumb.php referenced in there?

 

Seems like it should... just drop the product_thumb.php in the /admin directory and replace the tep_image function in /admin/includes/function/html_output.php...

 

If this version doesn't work in the admin part of your catalog, the new version won't either. ;)

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

Link to comment
Share on other sites

Hi

 

Yes sorry there was no change to the output of the pdf file.

I think it probably has to to with the following function within the PDF mod:

 

if(SHOW_IMAGES && strlen($data_array[12]))

{

//If Small Image Width and Small Image Height are defined

if(strlen($data_array[0])>1 && strlen($data_array[1])>1)

{

$this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

$y1=$this->GetY();

}

//If only Small Image Width is defined

else if(strlen($data_array[0])>1 && strlen($data_array[1]))

{

$heightwidth=getimagesize($data_array[12]);

$data_array[0]=$data_array[0];

$data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

 

$this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

$y1=$this->GetY();

}

//If only Small Image Height is defined

else if(strlen($data_array[0]) && strlen($data_array[1])>1)

{

$heightwidth=getimagesize($data_array[12]);

$data_array[0]=$width=$heightwidth[0]*PDF_TO_MM_FACTOR;

$data_array[1]=$data_array[1];

 

$this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

$y1=$this->GetY();

}

else

{

$heightwidth=getimagesize($data_array[12]);

$data_array[0]=$heightwidth[0]*PDF_TO_MM_FACTOR;

$data_array[1]=$heightwidth[1]*PDF_TO_MM_FACTOR;

 

$this->ShowImage($data_array[0],$data_array[1],$link,$data_array[12]);

$y1=$this->GetY();

}

 

 

But not being up on PHP i've got no idea where to start.

What it really needs to do i think is not check for the size, but who knows ;)

 

Cheers Richard

Link to comment
Share on other sites

Hi again

 

There's also this piece of code to do with images aswell:

 

function ShowImage(&$width,&$height,$link,$path)

{

 

$width=min($width,MAX_IMAGE_WIDTH);

$height=min($height,MAX_IMAGE_HEIGHT);

 

if(RESIZE_IMAGES)

{

$destination =DIR_FS_CATALOG."catalogues/";

 

 

if(substr(strtolower($path), (strlen($path)-4),4)==".jpg" || substr(strtolower($path), (strlen($path)-5),5)==".jpeg")

{

$src=imagecreatefromjpeg($path);

}

else if(substr(strtolower($path), (strlen($path)-4),4)==".png")

{

$src=imagecreatefrompng($path);

}

else

{

echo "Only PNG and JPEG";

exit();

}

 

$array=explode("/", $path);

$last=sizeof($array);

 

$size = getimagesize($path);

if($size[0] > $size[1])

{

$im=imagecreate($width/PDF_TO_MM_FACTOR, $height/PDF_TO_MM_FACTOR);

imagecopyresized($im, $src, 0, 0, 0, 0,$width/PDF_TO_MM_FACTOR, $height/PDF_TO_MM_FACTOR, $size[0], $size[1]);

}

else

{

$im=imagecreate($height/PDF_TO_MM_FACTOR,$width/PDF_TO_MM_FACTOR);

imagecopyresized($im, $src, 0, 0, 0, 0, $height/PDF_TO_MM_FACTOR, $width/PDF_TO_MM_FACTOR, $size[0], $size[1]);

}

if(!imagejpeg($im, $destination.$array[$last-1]))

{

exit();

}

 

$path=$destination.$array[$last-1];

 

$this->SetLineWidth(1);

$this->Cell($width,$height,"",1,0);

$this->SetLineWidth(0.2);

$this->Image($path,($this->GetX()-$width), $this->GetY(), $width, $height,'',$link);

$this->SetFont('Arial','',8);

 

unlink($path);

 

}

else

{

$this->SetLineWidth(1);

$this->Cell($width,$height,"",1,0);

$this->SetLineWidth(0.2);

$this->Image($path,($this->GetX()-$width), $this->GetY(), $width, $height,'',$link);

$this->SetFont('Arial','',8);

}

}

 

 

 

Cheers Richard

Link to comment
Share on other sites

It's clear that the PDF mod you mention has it's own method for rescaling images and does not make use of the tep_image function, so you are better off not using this mod with that...

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

Link to comment
Share on other sites

Great contribution, unfortunately it does not seem to work well with secure pages.

 

Any of the secure (https) pages do not show the right hand side header image (next to the page title) it just shows a broken image (red cross) with the page title next to the red cross.

 

Any Ideas???

 

Cheers.

Richard

The solution is never too far away ...

Link to comment
Share on other sites

Any of the secure (https) pages do not show the right hand side header image (next to the page title) it just shows a broken image (red cross) with the page title next to the red cross.

Not really, it's got nothin' to do with the mod, AFIAK...

 

Check your templates, paths, the way your server handles https docs, etc...

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

Link to comment
Share on other sites

Can anyone explain as what does this Mod really does.

 

I have installed it per instructions and it works for the Small Images on the Main page.

 

but when i move to the Product_Info page. Now image gets displayed.

 

I tried to check the address

 

http://www.domain.com/product_thumb.php?img=images//perfume/hugo.jpg&w=0&h=0

 

 

Can anyone point out as what is causing this problem.

 

Since i am looking for a Mod which will automatically rezise the Large Image to Medium Image in Product_info.

Edited by Farrukh
Link to comment
Share on other sites

solved the problem. It was a problem in the product_info.

 

 

I want to know that if its possible to resize the image to specified dimension.

 

 

For e.g.

 

I have set Small Images to 130x104

 

 

I have set Large Image to 400x399

 

 

I want that on the Product_Info page, the image should be resize from the Large Image (400x399) to Medium Image ( 170x126)

 

 

Is this possible with this mod.

Link to comment
Share on other sites

The mod retains the proper ratio of the original image when it scaled them, thus the size of the thumbnail image will be either the max width or max height that you specified for small images... As for intermediate sized images for the product detail page, see the original contrib page for an easy tip to set that...

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

Link to comment
Share on other sites

The mod retains the proper ratio of the original image when it scaled them, thus the size of the thumbnail image will be either the max width or max height that you specified for small images... As for intermediate sized images for the product detail page, see the original contrib page for an easy tip to set that...

Can you direct me to the Original Mod or its name

 

Thanks

Link to comment
Share on other sites

Hi Nate, first off I wanted to say THANK-YOU for this great contrib, it was easy to install and works perfectly the first time. Luckily I'm not having any of the problems that some are having (knocks on wood).

 

I do have a couple questions and enhancement ideas:

 

1) Would it be difficult to add a watermark feature so that I could automatically popup a copyright notice, etc. over the full-sized image when a user click "Enlarge Picture"? The other "OnTheFly" contrib does this (which worked well) but I couldn't get the rest of it to work. :( If there's nothing for this yet, maybe I'll try to add it in myself. Or is there another contrib that enhances your contrib for this?

 

2) Does the resizing process occur on all images (ie. .jpg and .gif)? I only need it to process .jpg's. I can't tell if there would be a speed improvement but it might be more effecient. I don't see any problems at all with how it works, just an idea.

 

Let me know if you have any ideas on this.

 

Thanks, -Chris.

Link to comment
Share on other sites

Would it be difficult to add a watermark feature so that I could automatically popup a copyright notice, etc. over the full-sized image when a user click "Enlarge Picture"?

Hi - I don't know give it a shot ;) This particular contrib does not make any adjustments to the full size image.

Does the resizing process occur on all images (ie. .jpg and .gif)?

The resizing occurs on any image where the width/height are not specified, *and* where the image is larger than the image width/heights specified. Thus, does not affect logos, box graphics, buttons, etc...

Have any of you got this contrib working in the admin?

I've given it a shot by replacing the admin's tep_image function, but it didn't work out... (also dump the product_thumb.php in the admin root dir)

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

Link to comment
Share on other sites

Hi Guys,

 

A slight problem has occured with my store, the one category has stop displaying the thumbnails when viewing the product, please look here.

 

Now the puzzling thing is if you look here the thumbnail is displayed!

 

The only thing that I can think of that must be causing the problem is the html_output.php file but not sure why?

 

Any ideas?

 

Thanks

 

Mark

Lifes a bitch, then you marry one, then you die!

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