Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Default image quality control


Reply

5 Posts   1964 Views

Avatar
Rawbit

7 January 2009 at 3:34am Community Member, 52 Posts

I'm interested in an easier way to control the default quality of uploaded images. So far i've been manually editing this line in GD.php:

protected static $default_quality = 75; // I change this to 100

The problem is each time I update SS, this is overwritten. Does anyone have a more practical suggestion for this that could be saved in mysite folder or in the database?

Also - it would be really nice to have this option not only in the admin area, but to allow a radiobox to chose between imageMagick and GD (I know this is a lot more work than it sounds). For now, I'm really only interested in a practical fix for controlling this image quality outside of GD.php

Avatar
UncleCheese

7 January 2009 at 3:55am 4085 Posts

You can probably do this:

_config.php

GD::set_stat('default_quality',100);

Avatar
Rawbit

7 January 2009 at 4:18am (Last edited: 7 January 2009 4:34am), Community Member, 52 Posts

UncleCheese,

Thanks for the replies - I tried this and got (on the upload tab and on attempting to flush):

Fatal error: Using $this when not in object context in C:\wamp\www\rob\silverstripe\sapphire\core\Object.php on line 387

I tried something different based on your idea:
GD::set_default_quality(100);

[edit] I'm not sure if it's working or not now

Avatar
UncleCheese

7 January 2009 at 4:43am 4085 Posts

Bah.. sorry about that.

singleton('GD')->set_stat('default_quality',100);

Avatar
Rawbit

7 January 2009 at 7:47am Community Member, 52 Posts

Excellent - seems to be working great. Thanks!