Gabriel R.
|
Tuesday 13 December 2005 8:46:57 am
I had the same problem and fixed it by doing following modifications.
1. lib/ezimage/classes/ezimageinterface.php Add a function called allocateTransparentColor to the eZImageInterface class:
function allocateTransparentColor ($color) {
imagecolortransparent( $this->ImageObject, $color );
}
2. lib/eztemplate/classes/eztemplateimageoperator.php
function modify( ...) {
...
if ( $ini->hasVariable( $class, 'AbsoluteWidth' ) )
$absoluteWidth =& $ini->variable( $class, 'AbsoluteWidth' );
if ( $ini->hasVariable( $class, 'AbsoluteHeight' ) )
$absoluteHeight =& $ini->variable( $class, 'AbsoluteHeight' );
/* START ADDITION */
$transparentBackground = false;
if ( $ini->hasVariable( $class, 'TransparentBackground' ) )
$transparentBackground = $ini->variable( $class, 'TransparentBackground' ) == "enabled";
/* END ADDITION */
...
$alternativeText = htmlspecialchars( $inputValue );
if ( is_string( $usecache ) )
$md5Text = $usecache;
else
/* START MODIFICATION */
//$md5Text = md5( $inputValue . $family . $size . $angle . $xadj . $yadj . $wadj . $hadj . $absoluteWidth . $absoluteHeight . implode( ",", $bgcol ) . implode( ",", $textcol ) );
$md5Text = md5( $transparentBackground. $inputValue . $family . $size . $angle . $xadj . $yadj . $wadj . $hadj . $absoluteWidth . $absoluteHeight . implode( ",", $bgcol ) . implode( ",", $textcol ) );
/* END MODIFICATION */
...
if ( is_string( $usecache ) or !$usecache or
!$this->hasImage( $this->CacheDir, 'imagetext', $md5Text, $alternativeText, $this->StoreAs ) )
{
$layer =& eZImageTextLayer::createForText( $inputValue, $font,
$wadj, $hadj, $angle,
$absoluteWidth, $absoluteHeight );
if ( !$layer )
{
$tpl->error( $operatorName, "Could not open font \"$family\", no image created", $placement );
return;
}
$layer->allocateColor( 'bgcol', $bgcol[0], $bgcol[1], $bgcol[2] );
$layer->allocateColor( 'textcol', $textcol[0], $textcol[1], $textcol[2] );
/* START ADDITION */
if ( $transparentBackground )
$layer->allocateTransparentColor($layer->color( 'bgcol' ));
/* END ADDITION */
$layer->setTextColor( 'textcol' );
if ( $storeImage )
$this->storeImage( $layer, $this->CacheDir, 'imagetext', $md5Text, $alternativeText, $this->StoreAs );
$layer->destroy();
}
else
...
} // end function modify
Usage in texttoimage.ini:
[arial]
Family=arial
PointSize=30
XAdjustment=0
YAdjustment=0
WidthAdjustment=8
HeightAdjustment=6
BackgroundColor=#ffffff
TransparentBackground=enabled
TextColor=#000000
Greets, Gabriel
|