21492 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1119 Views |
-
SetWidth background colour

16 December 2009 at 7:52am
Anyone know if there is a way to change it from white?
Something like: $image->bgcolour('hexvalue'); Maybe?
Mo
-
Re: SetWidth background colour

16 December 2009 at 8:28am
Hm. I was under the impression that SetWidth never creates a background?
Maybe you are referring to "PaddedImage" and the like? I had to change the color once and subclassed Image for that purpose.Something like:
class BetterImage extends Image
{
public function generatePaddedImage(GD $gd, $width, $height) {
return $gd->paddedResize($width, $height, 'cccccc');
}
public function SetWidth($width) {
if($width == $this->getWidth())
return $this;
return $this->getFormattedImage('SetWidth', $width);
}
public function SetHeight($height) {
if($height == $this->getHeight())
return $this;
return $this->getFormattedImage('SetHeight', $height);
}
}Then instead of using "Image", use "BetterImage" in your $has_one relations.
The above class also doesn't resize Images when they already have the correct dimensions which will improve quality... -
Re: SetWidth background colour

16 December 2009 at 11:44am
Sorry, I should have been more specific, I am using:
$Image.setWidth(80,80);
In the template language. It pads out the image if it has to, with a background colour.
I think I Ideally might have to use a similar method to scale and crop all images square, but the setWidth method would do for this stage of development.
Mo
-
Re: SetWidth background colour

16 December 2009 at 11:52am
I'm not aware of a way to alter the background color without subclassing or decorating. Simply create a subclass as proposed above and override the generate functions you need to customize.
-
Re: SetWidth background colour

16 December 2009 at 12:24pm
Hmm, I just found out I could do:
<% control croppedImage(80,80) %>
<img src="$URL" />
<% end_control %>Which is pretty much exactly what I wanted initially. I think you might be right about the subclassing. I will have to look into it
.
Cheers,
Mo
| 1119 Views | ||
|
Page:
1
|
Go to Top |


