[TYPO3-english] alpha background GIFBUILDER TYPO3 problem: Resolved!

Lukas Stancik webmaster at robe.cz
Fri Aug 7 14:53:57 CEST 2009


Hi Francisco & Ricardo,

thanks guys for sharing the solution, I'll give it a try during the weekend. 
Thanks again!

Regards, Lukas

Francisco Cifuentes napsal(a):
> Dear comunity:
> 
> In our team, Ricardo Mieres (working at e27.com, Berlin), has resolved this
> trouble, and how I've promised, we will share the solution. We hope that
> this can help in this problem. Our solution is based in this method :
> 
> (Thanks again Lukas and Tomas!!)
> 
> function getTYPO3Image($image){
> 
>     /**
>     * @author: z27 at e27.com
>     *
>     **/
>     if(is_file($this->conf['imageTransparency'])){
>         $finalImg = @imagecreatefrompng($this->conf['imageTransparency']);
>         if($finalImg){
>             imagealphablending($finalImg, false);
>             imagesavealpha($finalImg, true);
> 
>             foreach($this->conf as $keyElement=>$imgElementSetup){
>                $elementNameArray=split('_',$keyElement);
>                if($elementNameArray[0]=='image' and
> $this->conf[$keyElement]=='IMAGE' ){
>                    $tempImgSetup=$this->conf[$keyElement.'.'];
>                        foreach($tempImgSetup['file.'] as $keyTsObj=>$value){
>                            if($value=='TEXT'){
> 
> $tempImgSetup['file.'][$keyTsObj.'.']['text']=$image[$elementNameArray[1]];
>                            }
>                            if($value=='IMAGE'){
> 
> $tempImgSetup['file.'][$keyTsObj.'.']['file']='uploads/pics/'.$image[$elementNameArray[1]];
>                            }
>                        }
>                   $impTempStr=$this->cObj->IMAGE($tempImgSetup);
>                   $img2InsertInfo=$GLOBALS['TSFE']->lastImageInfo;
>                   if(is_file($img2InsertInfo[3])){
>                        $tempImg=@imagecreatefromgif($img2InsertInfo[3]);
>                        imagealphablending($tempImg, false);
>                        imagesavealpha($tempImg, false);
>                        imagecopymerge  ( $finalImg  , $tempImg  ,
> $this->conf[$keyElement.'.']['posX'] ,
> $this->conf[$keyElement.'.']['posY']  , 0 , 0  , $img2InsertInfo[0]  ,
> $img2InsertInfo[1] ,100);
>                        imagedestroy($tempImg);
>                   }
>               $temp.=$elementNameArray[1];
>               }
>         }
> 
> $fileName=t3lib_div::shortMD5($image.$temp+$this->conf['imageTransparency'].$image['image']);
>         $fileName='typo3temp/GB/'.$fileName.'.png';
>         imagepng($finalImg,$fileName);
>        }
>     }
>     return '<img class="layer open"  longdesc=""
> id="content_'.$image["uid"].'"  src="'.$fileName.'" />';
> }
> 
> 
> Best regards,
> 
> Francisco.
> ________________________
> 
> Francisco A. Cifuentes Silva
> Ingeniero de Proyectos
> Instituto de Informática Educativa
> Universidad de la Frontera
> Temuco, Chile
> Tel: +56 45 325277
> Fax: +56 45 325263
> http://www.iie.ufro.cl
> 
> 
> 
> 2009/8/4 Lukas Stancik <lukas.stancik at robe.cz>
> 
>> Hi Francisco,
>>
>> IMHO it can not be achieved at all. I mean without changing the core.
>> The combine/composite command of ImageMagick is always called with
>> "+matte" option (see t3lib/class.stdgraphic.php around line 2549) which
>> disables the alpha channel of the output image.
>>
>> I have tried to set it to "-matte" and "-alpha On" but without any effect
>> :(
>>
>> But trying to run this in console:
>> Note: image1.png contains some graphic with transparent background,
>> image2.png is fully opaque
>>
>> composite -compose src-over -matte image2.png image1.png output.png
>>
>> behaves as intended = the resulting image is a composition of the two
>> images with transparent background...
>>
>> Regards,
>>
>> Lukas
>>
>> Francisco Cifuentes napsal(a):
>>> I get the combined image, but the background lose the transparency.
>>>
>>>
>>> ________________________
>>>
>>> Francisco A. Cifuentes Silva
>>> Ingeniero de Proyectos
>>> Instituto de Inform�tica Educativa
>>> Universidad de la Frontera
>>> Temuco, Chile
>>> Tel: +56 45 325277
>>> Fax: +56 45 325263
>>> http://www.iie.ufro.cl
>>>
>>>
>>>
>>> 2009/8/3 Tomas Mrozek <mail at cascaval.com>
>>>
>>>> Can you upload somewhere those two images ("background.png" and
>>>> "imageToShow.jpg") and the output image that you get?
>>>>
>>>> Tomas Mrozek
>>>> _______________________________________________
>>>> TYPO3-english mailing list
>>>> TYPO3-english at lists.netfielders.de
>>>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>>>>
>> _______________________________________________
>> TYPO3-english mailing list
>> TYPO3-english at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>>


More information about the TYPO3-english mailing list