Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 11
Avoid image compression with GD2
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

Hi,

I would like to get a fine control on the quality of my product images. In others terms, I’d like not to use GD to compress my pictures.

Today I upload images in jpg 100% and I already setted the quality to something better than the default value (in lib/Varien/Image/Adapter/Gd2.php) but the result is not good for all image types (depending on the size, product, ...).

I would like to disable the Gd2 processing in the image caching system to replace it by a simple file copy ... in order to avoid any processing and keep a “human validated” quality wink

Any idea to do this properly ?

Thanks !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

Can you unload the GD module from the server?  If that’s possible and practical (no other projects need it) then do it and search for my post about “gd got you down?” That post will show you how to compensate for a missing GD extension and use the regular images that you’ve uploaded.

 
Magento Community Magento Community
Magento Community
Magento Community
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

Thanks for your reply. Unfortunately if I disable the php gd extension + delete image cache no more product is displayed in the shop.

I’ll need to look at the code, but I don’t really know how to manage this right.

Varien, any advise about the method ? Where would you make changes for this feature ?

Thanks !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Roy Andre
Sr. Member
 
Avatar
Total Posts:  209
Joined:  2007-08-31
 

I would also very much like to see an option in the admin-area where we could ajust the image-quality wanted for uploaded images.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lee Nugent
Jr. Member
 
Avatar
Total Posts:  25
Joined:  2008-03-27
 

I’d like to sort out the default image compression.  I’m a strong believer that good images sell more products… GD2 settings currently dont cut the mustard!

Lee.

 
Magento Community Magento Community
Magento Community
Magento Community
 
PitchOu
Member
 
Total Posts:  39
Joined:  2008-02-04
Villeneuve d'Ascq, France
 

If you use only jpg images, you can change the code like this in lib/Varien/Image/Adapter/Gd2.php :

Change
case IMAGETYPE_JPEG:
imagejpeg($this->_imageHandler, $fileName);
break;

to

case IMAGETYPE_JPEG:
imagejpeg($this->_imageHandler, $fileName, 95);
break;

To get a default compression of 95% instead of the default value (75%).

Hope it helps !

 
Magento Community Magento Community
Magento Community
Magento Community
 
sdb
Sr. Member
 
Avatar
Total Posts:  223
Joined:  2007-11-13
coastal California, USA
 

this is a great thing to know. i haven’t noticed any issues with the default 75%, but then again i use lineart instead of photos.

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

Does that solution actually work? Same thing that happened to me on the thread below happens when I try to apply this fix:

http://www.magentocommerce.com/boards/viewthread/7822/#t33356

Mark

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

I actually don’t even see that supported in PHP documentation.

- Mark

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shpigford
Sr. Member
 
Avatar
Total Posts:  171
Joined:  2007-09-03
Denver, CO
 

circa1977, make sure you are modifying imagejpeg() and NOT imagecreatefromjpeg().

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

Thanks, Josh. That worked much better.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

It looks so much better now!  Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

worked for me, but image upload is broken now.

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

Did this change since the newest release?

case IMAGETYPE_JPEG
imagejpeg($this->_imageHandler$fileName); 
break;

.. does not appear to be anywhere in Gd2.php ..

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

Try to change the quality in

/app/code/core/Mage/Media/Model/File/Image.php

on line 168 from

$result imagejpeg($object->getTmpImage(), $object->getFilePath(true), 80);

to

$result imagejpeg($object->getTmpImage(), $object->getFilePath(true), 95);
 
Magento Community Magento Community
Magento Community
Magento Community
 
AngelEyes
Member
 
Total Posts:  74
Joined:  2008-02-25
 

Scree,

Brilliant, thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 11