| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Resize thumbnails with GD | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Resize thumbnails with GD
It got me frustrated: having a nice looking shop with very ugly by browser resized images. I didn't want that anymore and looked for a solution. So I found one.
It resizes thumbnails on the fly and stores them on the server, so it only needs to do this once for every image and not over and over again. This mod will save you a lot of bandwidth when you have a lot of products and customers. Also see the difference: These are actual screenshot from my shop: BEFORE MOD: http://www.popelectronics.nl/img/before.jpg http://www.popelectronics.nl/img/before1.jpg AFTER MOD: http://www.popelectronics.nl/img/after.jpg http://www.popelectronics.nl/img/after1.jpg This is how to do it: First we'll need to download a php script by Joe Lencioni called Smart Image Resizer: http://shiftingpixel.com/2008/03/03/smart-image-resizer/ Once you unpacked the image.php file rename it to imager.php (because there already is such a file in X-Cart, we don't want to overwrite that one). Upload the file into your X-Cart installation folder. Next make a folder and name it: imagecache Make sure this folder is writable (777) Now we need to change 1 file. Make sure you have a backup. VERSION 4.1.8-4.1.9 skin1/product_thumbnail.tpl REPLACE: Code:
WITH: Code:
VERSION 4.1.11 skin1/product_thumbnail.tpl REPLACE: Code:
WITH: Code:
Now run: www.[yourxcartsite].com/cleanup.php (replace this with your own site ) That's it! Note: this will only work if you have the images on the server (filesystem), not when you have images in the database. Have fun with it! I hope you enjoy and if so let me know by posting a reply here.
__________________
X-Cart 4.7.7 Fashion Walk template CDSEO pro, remember anoymous carts, checkout one and some mods I've done myself (ideal, froogle, export shipping labels) @Linux php5.6, mysql5.6, dedicated server iDeal Advanced v3.3.1 integration |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
Thank you. This looks like a very simple modification that if it works well will be a real time saver. Unfortunately, I don't have the time to check it out right now but will keep it for future reference.
__________________
Two Separate X-Cart Stores Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series. Integrated with Stone Edge Order Manager + POS Version 4.1.12 Gold (fresh install) - X-AOM - Linux Mods - XCSEO free |
|||||||||
#3
|
|||||||
|
|||||||
Re: Resize thumbnails with GD
Added the same function for 4.1.11 installs, it is a little different. See 1st post.
Also added before and after pictures. So you see this makes a big improvement on thumbnails and even takes less bandwidth, because when your normal image is let's say 20kb and the browser resizes it it is still 20kb. When you use the resize mod it's likely to be about 3-5kb. Now this doesn't do a lot for 2 customers but on busy sites with hundreds of customers a day this will improve your website speed as well.
__________________
X-Cart 4.7.7 Fashion Walk template CDSEO pro, remember anoymous carts, checkout one and some mods I've done myself (ideal, froogle, export shipping labels) @Linux php5.6, mysql5.6, dedicated server iDeal Advanced v3.3.1 integration |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
What does this do exactly?
Does it eliminate the need to upload thumbnails to the images/T/ folder?
__________________
Two Separate X-Cart Stores Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series. Integrated with Stone Edge Order Manager + POS Version 4.1.12 Gold (fresh install) - X-AOM - Linux Mods - XCSEO free |
|||||||||
#5
|
|||||||
|
|||||||
Re: Resize thumbnails with GD
The way I use my shop is upload just 1 image for every product, the large image (this is besides detailed images, just on the add product page). I always use the top image, leave the 2nd image blank.
What X-Cart does is resize the images you have uploaded in the browser to the width you entered in the options (for my shop it's 145 pixels wide, however most pictures I upload are around 300-400 pixels wide). What this mod does is resize the image through the GD library on the server and save it into the filesystem, so it doesn't need to resize the picture every single time (just like the template cache you have). This will save bandwidth, time (because you don't have to resize yourself and upload 2 images) or when you don't upload 2 pictures like me it saves a lot of frustration because of ugly looking browser scaled images. It saves bandwidth because the browser normally receives the full image (20kb or so) and resizes them according to your specifications. This script resizes them by using the GD library so they still look nice and sharp, then it saves it so you only have a 2-5kb download for each image. I actually never uploaded images myself, besides doing so through the admin page in the thumbnail entry. This is how I upload all of my pictures: http://www.popelectronics.nl/img/screen.jpg This also works for large images: http://www.popelectronics.nl/img/screen2.jpg I never use any other option and never upload more than 1 image. With the mod they all look nice, wherever you put them in your shop. Have a look at www.popelectronics.nl so you can see for yourself.
__________________
X-Cart 4.7.7 Fashion Walk template CDSEO pro, remember anoymous carts, checkout one and some mods I've done myself (ideal, froogle, export shipping labels) @Linux php5.6, mysql5.6, dedicated server iDeal Advanced v3.3.1 integration |
|||||||
#6
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
Resizing with GD has one pitfall - thumbnails look too soft. This is why the upcoming version 4.2 not just resizes images with GD, but also applies "unsharp mask" filter on thumbnails that makes the thumbs clean and sharp.
Note: I've just looked through the Smart Image Resizer (the link posted above) code and noticed that it applies a "sharpness" filter on images too (it uses imageconvolution() function that is available starting from php 5.1.0). |
|||||||||
#7
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
xplorer:
1. Maybe I am not happy by the results of your default values for the unsharp mask effect. Can we control the values the "unsharp mask" filter effect inside the script (Amount, Radius, Threshold)? 2. Did you use Unsharp Mask for PHP (http://vikjavev.no/computing/ump.php)?
__________________
X-Cart Next: Business 5.2 (learning and testing) X-Cart Classic: Gold and Gold Plus 4.7 Lots of Modules and Customizations OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions) You can catch my ideas here: http://ideas.x-cart.com |
|||||||||
#8
|
|||||||
|
|||||||
Re: Resize thumbnails with GD
Hi love how easy this is to use! I applied it to my detailed images!!
I have 4.11 heres the code if anyone wants it! Code:
Need a bit of help applying it to the normal images though?? I don't kow about the whole {include= product thumb... ) dealo?
__________________
x-cart 4.1.11 yay finally starting to get the hang of this stuff!! site: www.slixaustralia.com.au |
|||||||
#9
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
Nice..mod
Quote:
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
#10
|
|||||||||
|
|||||||||
Re: Resize thumbnails with GD
This works great with everything except Download Expander. Download Expander calls the following:
HTML Code:
Unfortunately, the above code displays no image , however, everything else seems to work just fine. Thanks for the post!
__________________
XCART 4.1.8 [Linux] |
|||||||||
|
|||
X-Cart forums © 2001-2020
|