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 2 of 11
Avoid image compression with GD2
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

much better would be to extend the method of this class of course…

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 
scree - 11 September 2008 07:30 AM

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);

Great, thanks for this. Best to put this in a local app/code/local… folder to prevent overwriting it when updating. Should be in the GUI backend.
Thanks!!

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

Where would this go in the local folder since it’s parent folder is not in the core folder?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 

Hi sherrie,

maybe here:

app/code/local/Mage/Media/Model/File

?

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

Ohhhh it is in the core folder now, sorry - I totally missed that, I thought we were still talking about the Gd2.php file from before. That’ll teach me to half-read something!

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidn
Jr. Member
 
Total Posts:  24
Joined:  2008-08-14
 

After upgrading to 1.1.6 my image compression settings were overwritten. So following these directions I went back and changed them again. This time though it has no effect. In fact the images are just being crushed, they look really bad. Has anyone else noticed this? Is there another way to adjust the compression?

Thanks
~David

 
Magento Community Magento Community
Magento Community
Magento Community
 
acstudios
Jr. Member
 
Total Posts:  15
Joined:  2008-08-19
 

Any solutions or suggestions on this with version 1.1.6?

 
Magento Community Magento Community
Magento Community
Magento Community
 
TheTwistedOne
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2008-09-20
 

I´m also having problems with this.

The mod described by Scree dosen´t seem to work in version 1.1.6

Help!!! images look terrible!

 
Magento Community Magento Community
Magento Community
Magento Community
 
TheTwistedOne
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2008-09-20
 

Ok, solution found for version 1.1.1 and above including 1.1.6

The code is in /lib/Varien/Image/Adapter/Gd2.php , PLEASE note if you are using 1.1.6 the line to change is 80, NOT 68.

00christian00 - 31 July 2008 04:22 AM

In version 1.1 the code has changed.
To up the quality change the line 68

call_user_func($this->_getCallback('output'), $this->_imageHandler$fileName);

to
if (IMAGETYPE_JPEG === $this->_fileType)call_user_func($this->_getCallback('output'), $this->_imageHandler$fileName,90);
        else 
        
call_user_func($this->_getCallback('output'), $this->_imageHandler$fileName);

90 is my quality,change to your preference.Remember to clear the image cache to test.

Remember 1.1.6 users change line 80

Many thanks to 00christian00 for this fix, you rock!

 
Magento Community Magento Community
Magento Community
Magento Community
 
acstudios
Jr. Member
 
Total Posts:  15
Joined:  2008-08-19
 

Hey TheTwistedOne!  This definitely worked.  Thanks for posting this up!

 
Magento Community Magento Community
Magento Community
Magento Community
 
TheTwistedOne
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2008-09-20
 

@AcStudios, i´m glad it helped.

Full credit should go to 00christian00 for working this one out.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kasper
Jr. Member
 
Total Posts:  29
Joined:  2007-11-11
Denmark
 

Nice tip, but how would you go about implementing this so that it wont get overwritten when updating magento?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tilzinger
Sr. Member
 
Total Posts:  126
Joined:  2007-12-27
 
Kasper - 07 October 2008 10:48 PM

Nice tip, but how would you go about implementing this so that it wont get overwritten when updating magento?

Create a .txt file in the root of your site that says READMEWHENUPDATING and note the changes you need to make to core files. smile

And yes, a setting like this should most definitely be editable in the Admin area.

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

@tilzinger, this feature in the Admin Area is crucial.

Dear Magento Team, take note!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
lisali
Enthusiast
 
Avatar
Total Posts:  889
Joined:  2008-04-28
London, UK
 

Agree. We need to be able to customise this in the admin.

Magento applies WEIRD image compressions. Also - has anyone noticed something strange happening when uploading PNG images? For one - their size gets BIGGER (2-3 times) in the frontend. And then there are some transparency issues.

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