17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3003 Views |
-
Greyscaling and resizing images not working?

15 December 2008 at 10:43pm Last edited: 15 December 2008 10:43pm
For some reason I can't get the greyscale to work with a resize:
function generateLogoH30Grey($gd) {
$gd->setQuality(100);
$gd->paddedResize(70,30);
return $gd->greyscale();
}
The above example gives me back grey images, but they are the original size (so paddedresize is cancelled) rather than width 70 and height 30.function generateLogoH30Grey($gd) {
$gd->setQuality(100);
$gd->greyscale();
return $gd->paddedResize(70,30);
}
And the above gives me resized images as expected but then the greyscale is cancelled (so the images are back in color).Does anybody have any experience with resize/greyscale combinations? What am I overlooking?
I looked at the code in the gd class, and it would seem that it should work either way....?
-
Re: Greyscaling and resizing images not working?

15 December 2008 at 11:05pm
I think your problem may be that your changes are not carried over to the next line of code - each of these methods return a new instance of the GD class rather than modifying the existing one. Have you tried chaining your methods together?
public function generateLogoH30Grey($gd) {
return $gd->setQuality(100)->paddedResize(70, 30)->greyscale();
} -
Re: Greyscaling and resizing images not working?

15 December 2008 at 11:17pm
Thanks for your reply, ajshort!
That is a very good point, and when I read your post I thought, "Duh! That's it!". But unfortunately I'm getting even bigger problems when chaining:
Fatal error: Call to a member function paddedResize() on a non-objectSo, that's not the solution, or the syntax of the chaining is incorrect.
By the way, the one $gd per line style is according to the docs: http://doc.silverstripe.com/doku.php?id=imageupload (under the 'More advanced uses' heading, there's an example).
-
Re: Greyscaling and resizing images not working?

15 December 2008 at 11:34pm
I had a quick look at the GD class - some functions do create a new instance, others don't. Maybe try:
public function generateLogoH30Grey(GD $gd) {
$gd = $gd->PaddedResize(70, 30)->greyscale();
$gd->setQuality(100);
return $gd;
}
| 3003 Views | ||
|
Page:
1
|
Go to Top |


