| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Detailed Product Images Module - Changing Unsharp Mask Filter Parameters | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Detailed Product Images Module - Changing Unsharp Mask Filter Parameters
By default Unsharp Mask Filter parameters are: Amount = 120, Radius = 0.4, Threshold = 1. Parameters are stored here: [X-Cart_DIR]/include/lib/phpunsharpmask.php
Maybe some of you are not happy with these values because the resized images look bad. No problem you can change the parameters in line 28: function UnsharpMask($img, $amount = 120, $radius = 0.4, $threshold = 1). I am one who did not like this approach, editing a php file. I requested many times after v4.2 was released, to set up the parameters in Admin. Having no solutions, I did it myself and I would like to share with you this. It is an elegant way, and hope QT to insert it by default in the next XC versions. We will insert Amount, Radius, Threshold in Admin -> Detailed Product Images Module. 1) Delete default values in phpunsharmask.php file - go to: [X-Cart_Dir]/include/lib/phpunsharpmask.php - line 28 original: function UnsharpMask($img, $amount = 120, $radius = 0.4, $threshold = 1) modify: function UnsharpMask($img, $amount, $radius, $threshold) 2) Call parameters in func.images.php - go to: [X-Cart_Dir]/include/func/func_image.php - line 1143 original: if (function_exists('UnsharpMask')) $_image = UnsharpMask($new_image); modify: if (function_exists('UnsharpMask')) { $amount = $config['Detailed_Product_Images']['det_unsharpmask_amount']; $radius = $config['Detailed_Product_Images']['det_unsharpmask_radius']; $threshold = $config['Detailed_Product_Images']['det_unsharpmask_threshold']; $_image = UnsharpMask($new_image, $amount, $radius, $threshold); } 3) Adding parameters values in database Execute these SQL queries: INSERT INTO `xcart_config` VALUES ('det_unsharpmask_amount', 'Unsharp mask - Amount', '120', 'Detailed_Product_Images', 60, 'numeric', '120', '', ''); INSERT INTO `xcart_config` VALUES ('det_unsharpmask_radius', 'Unsharp mask - Radius', '0.4', 'Detailed_Product_Images', 61, 'numeric', '0.4', '', ''); INSERT INTO `xcart_config` VALUES ('det_unsharpmask_threshold', 'Unsharp mask - Threshold', '1', 'Detailed_Product_Images', 62, 'numeric', '1', '', ''); 4) Adding language labels for parameters values in database Execute these SQL queries: INSERT INTO `xcart_languages` VALUES ('en', 'opt_det_unsharpmask_amount', 'Unsharp Mask - Amount', 'Options'); INSERT INTO `xcart_languages` VALUES ('en', 'opt_det_unsharpmask_radius', 'Unsharp Mask - Radius', 'Options'); INSERT INTO `xcart_languages` VALUES ('en', 'opt_det_unsharpmask_threshold', 'Unsharp Mask - Threshold', 'Options'); Now you can change Unsharp Mark Filter parameters in Detailed Product Images Module and forget about editing php files. I did not know how to update all images in cache, after changing a parameter value. That's why I recommended after changing parameters to modify one of the maximum size of an image to get the new results. Hope with your contribution to do this also. Happy New Year!
__________________
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 |
|||||||||
|
#2
|
|||||||||
|
|||||||||
Re: Detailed Product Images Module - Changing Unsharp Mask Filter Parameters
Quote:
Thank you for the post, much appreciated! I find it very useful and I hope all X-Carters do as well. We contemplated the idea of adding these parameters to the settings, but then came to a conclusion that they might be confusing and not as informative for the average X-Cart user who is not as experienced in design as you. However, we are planning to add an article to our online help portal at http://help.x-cart.com/ which describes how to adjust sharpness for the thumbnails
__________________
Alexander Dyachkov, Director of Customer Success |
|||||||||
#3
|
|||||||
|
|||||||
Re: Detailed Product Images Module - Changing Unsharp Mask Filter Parameters
My business sales clothes online, so images are everything but I don't know that much about this you're talking about. Can we visually see the difference in images in an example here? Thank for this code!
__________________
X-Cart Classic 4.4.X |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Detailed Product Images Module - Changing Unsharp Mask Filter Parameters
Let's update this old thread with automatically re-generation image cache after changing one of the values for Amount, Radius, Threshold
1) Open file: [XC_Dir]/[ADMIN_Dir]/configuration.php 2) Search for the following string: "// Regenerate image cache" (without quotes) 3) After this PHP Code:
4) Paste this PHP Code:
Now change any of the values for Amount, Radius, Threshold and you will get automatically re-generation of your image cache. There is no need to go in Maintenance all the time after changing a value. After this final step in my humble opinion this should be a "must have" inside the next XC4 version (4.5.1 as well). No more hard coded for unsharp mask values, re-generation, ugly thumbs. P.S. We should do something with the tabs in product page. No more hard coded there too. Personally I know how to deal with new tabs, sorting, hiding, but how many of us know how to do this? Please take in consideration an elegant way for creating, hiding, arranging tabs in Admin interface (4.5.2). It is not complicated at all guys.
__________________
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 |
|||||||||
#5
|
|||||||||
|
|||||||||
Re: Detailed Product Images Module - Changing Unsharp Mask Filter Parameters
One more thing, I think admin/configuration.php has some issues with re-generation. This needs an investigation. For example if section is Appearance the results are not the same like section is Tools. Re-generating image cache from Maintenance section never gives problems. But for other sections there are: Detailed Image Product, Appearance. I reported this in Bugtracker.
__________________
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 |
|||||||||
|
|||
X-Cart forums © 2001-2020
|