| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Resizing Images During Upload Using ImageMagick | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Resizing Images During Upload Using ImageMagick
I'm posting this in the hope it will grow into a full fledged function that will simplify image handling in X-cart. The code I'm posting is all I needed, but I can envision it being extended to apply more of ImageMagick's (http://ImageMagick.org) or GraphicsMagick's (http://GraphicsMagick.org) power to manipulate images. Another variation could apply PHP image functions to get similar results.
Problem: I found it difficult and time consuming to train administrators of the shopping cart to edit and upload images properly, resulting in images that were too large or of poor quality. This is a relatively simple modification that resizes (if needed) category icons, product thumbnails, and product detailed images when they are being uploaded. Requirements and limitations: You need to have ImageMagick or GraphicsMagick on your server. This code only changes the size of the image if it's over a set width, which is all I was concerned with. Notes: This has only been tested on X-cart 4.0.13 with images stored in the database. You need add code in three files: /admin/category_modify.php /include/product_modify.php (add in two places) /modules/Detailed_Product_Images/product_images_modify.php In these files find the line of code: Code:
Add this code after it and set the $maximum_file width variable to the desired size: Code:
Test results: Upload file: test.jpg 1734 x 1128 (1,761,608 bytes) $maximum_file_width = 150 produced a reduced file of 150 x 98 (14,752 bytes) $maximum_file_width = 400 produced a reduced file of 400 x 260 (91,589 bytes) I don't expect to spend much more time on this, but I hope some of you will find this useful and hopefully make improvements.
__________________
r.jones X-Cart Version 4.0.13 |
|||||||
#2
|
|||||||
|
|||||||
Re: Resizing Images During Upload Using ImageMagick
What are the codes if the image stored in file system?
|
|||||||
#3
|
|||||||||
|
|||||||||
Re: Resizing Images During Upload Using ImageMagick
Quote:
__________________
Paul Dodman e-business & m-commerce consultant w: www.luminointernet.com e: xcart@luminointernet.com Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart. |
|||||||||
#4
|
|||||||
|
|||||||
Re: Resizing Images During Upload Using ImageMagick
Quote:
Hi, pauldodman any solution about file system stored images? |
|||||||
#5
|
|||||||||
|
|||||||||
Re: Resizing Images During Upload Using ImageMagick
Hi Learner
This is R.Jones' mod - nothing to do with me - maybe he'll post a reply for you.
__________________
Paul Dodman e-business & m-commerce consultant w: www.luminointernet.com e: xcart@luminointernet.com Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart. |
|||||||||
#6
|
|||||||
|
|||||||
Re: Resizing Images During Upload Using ImageMagick
Ideally, this should be accomplished with GD as most servers already have it installed.
Just my 2 cents worth. Greg
__________________
Greg Marler x-Cart GoldPlus version 4.7.12 Gold 4.7.6 (under construction) CentOS Apache 2 |
|||||||
#7
|
|||||||
|
|||||||
Re: Resizing Images During Upload Using ImageMagick
You should just use GD, I've completely eliminated all thumbnails on our site by integrating in a script that I got for free. Just google GD image resizer script image.php
It looks like you are trying to resize image on upload, it would be better if you just allow a hi-rez image to upload and leave it in its dimensions. The idea of actually having multiple images upload with different sizes is completely out dated and bad. Our site also has zoomify so we only need one image to be upload for each product and done, all sections of the site are populated with one image from any thubnail size, up to hi-rez image zooming, and zoomify isn't as slow as that joke of a module that qualiteam has for zooming images which again requires a separate image to be uploaded.
__________________
XCART-PRO:Version 4.1.11 Add-on: X-FeatureComparison Add-on: X-SpecialOffers Add-on: X-Magnifier Add-on: X-Survey Add-on: X-AOM (Advanced Order Management) Add-on: X-FancyCategories |
|||||||
|
|||
X-Cart forums © 2001-2020
|