21474 Posts in 5781 Topics by 2620 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 831 Views |
-
Flip an Image

8 September 2010 at 2:47am
Hello,
I try to add a new function to the Image class which will flip an image horizontally, vertically or both. It should work exactly the same way like SetRatioSize only with an additional parameter.
I added the following Code to the Image class as a first tryout:
public function SetFlipImage($width, $height, $type) {
return $this->getFormattedImage('SetFlipImage', $width, $height);
}
public function generateSetFlipImage(GD $gd, $width, $height, $type){
return $gd->resizeRatio($width, $height);
}But when calling from Template with $Image.SetFlipImage(248,123,hor) Silverstripe stops with:
[Warning] Missing argument 1 for Image::SetFlipImage(), called in /public_html/silverstripe_base/sapphire/core/ViewableData.php on line 369 and defined
That I do not understand, because removing the last argument leads to
[Warning] Missing argument 3 for Image::SetFlipImage()
which is absolutely correct. Why does Silverstripe not recoginize my third parameter?
-
Re: Flip an Image

8 September 2010 at 6:20pm
public function SetFlipImage($width, $height, $type) {
return $this->getFormattedImage('SetFlipImage', $width, $height);
}public function generateSetFlipImage(GD $gd, $width, $height, $type){
return $gd->resizeRatio($width, $height);
}Change the name of one of your functions. SetFlipImage and generateSetFlipImage are essentially the same function name, because the word generate gets dropped off.
That is, calling $Image.SetFlipImage() will call either of these functions, and it looks like it's calling the second function.The warning you are getting from Silverstripe is you are Missing 1 argument. It expects 4 arguments, because it is trying to call the generateSetFlipImage function.
-
Re: Flip an Image

8 September 2010 at 8:39pm
Well, I figured out how to use the functions...however, I stumbled upon the following lines in several function of the GD class.
$output = clone $this;
$output->setGD($newGD);
return $output;Is there a special reason for that? I'd like to return right away just $this with $this->gd holding my flipped image.
| 831 Views | ||
|
Page:
1
|
Go to Top |


