Menu

News

Monday 20. of November 2006 Speed up PHP5 and Mysql on osx

Friday 01. of September 2006 New version of phpadsnew

Wednesday 26. of July 2006 Me and my macBook

Saturday 03. of June 2006 Advanced pop-up and acronym manager

Site Sponsors

Advertise using Text-Link-Ads

CMS Solutions

System CMS

 

Foro Apple

Foro Apple

 

Cocktails

Cocktails of the World

of the world!

Want to advertise here?

Single page or site-wide advertisements. Gain your PR with back-links from a high ranked site.

Click here to request more information

Guidbuilder Experiments in Typo3

Here if will do some experiments in GIFBUILDER. I will show some simple example, experiments and tests. From font rendering to multi-transparancy test recently created by Kraft Bernhard from Opens external link in new windowThink Open.

What is GIFBUILDER:

GIFBUILDER (written with capitals) Is a system in Opens external link in new windowTypo3 that can create images on the fly. The name GIFBUILDER was originated from the fact that back in the old ages it could only create GIF images, nowdays it will also process and create PNG and JOG images on the fly.

One thing to know is where to find documentation for GIFBUILDER. I would suggest bookmark Opens external link in new windowTSREF now if you didn't so already.

Wat can gifbuilder do for you?

GIFBUILDER can create images! You know, nowdays with this beautifull image manimulation programs the designers create the most challaging layouts which we need to put in a CMS.

For example, the header above this page is build with GIFBUILDER. Fully automaticly! When I change the text of the header of this article, GIFBUILDER builds a new image for me. No need for Photoshop, the Gimp etc for creatinmg the headers! Cool he?

Here is how the code looks like to generate the header above:

cHeader = IMAGE
cHeader {
    alttext.cObject = TEXT
    alttext.cObject.field = header
    wrap = <h1>|</h1>
    file = GIFBUILDER
    file {
        format = gif
        reduceColors = 8
        transparentColor = #f6f2ea
        XY = [10.w]+14,[10.h]+2
        backColor = #f6f2ea
        10 = TEXT
        10 {
            text.field = header
            fontSize = 38
            fontColor = #280505
            offset = 0,28
            fontFile = fileadmin/templates/fonts/edwastic.ttf
        }
    }
}

lib.stdheader < cHeader

Berhards Multi-transparency test

As prommised for Bernhard I was going to do some testing for multi-transparency tests in GIFBUILDER.

Typoscript Code I used for the default below.

transorg = IMAGE
transorg {
    wrap = <h1>|</h1>
    alttext.cObject = TEXT
    alttext.cObject.value = Origional
    titleText.cObject = TEXT
    titleText.cObject.value = Origional
    file = GIFBUILDER
    file {
        format = png
        XY = 100,75
        4 = IMAGE
        4.file = fileadmin/images/multitranstest.png
    }
}

Origional

Here only the black block is removed

transblack  < transorg
transblack {
    alttext.cObject.value = Black transparent
    titleText.cObject.value = Black transparent
    file.transparentColor = #000000
}

Black transparent

Last but not least we remove the blue color and the cyan color in the middle of the blocks

transcyanblue  < transorg
transcyanblue  {
    alttext.cObject.value = Blue ands Cyan Transparent
    titleText.cObject.value = Blue ands Cyan Transparent
    file.transparentColor = #0000ff | #00ffff
}

Blue ands Cyan Transparent

Modified function unifyColors(....)

I did do some code cleanup in the function unifyColors(...) found in the class t3lib_stdgraphic.

The option with two colors didn't work properly and I suspect there is a bug in Graphic Magic that doesn't reduce colors correctly on palette based images. I will not jump into detail, but below you can find the modified function. That will correct the two bugs.

 

 

    /**
     * Unifies all colors given in the colArr color array to the first color in the array.
     *
     * @param    pointer        Image resource
     * @param    array        Array containing RGB color arrays
     * @param    [type]        $closest: ...
     * @return    integer        The index of the unified color
     */
    function unifyColors(&$img, $colArr, $closest = false)    {
        $retCol = -1;
        if (is_array($colArr) && count($colArr) && function_exists('imagepng') && function_exists('imagecreatefrompng'))    {
            $firstCol = array_shift($colArr);
            $firstColArr = $this->convertColor($firstCol);
            $firstCol = $this->hexColor($firstColArr);
            if (count($colArr)>=1)    {
                $imgName = $this->randomName().'.png';
                $this->imageWrite($img, $imgName);
                foreach ($colArr as $transparentColor)    {
                    $transparentColor = $this->convertColor($transparentColor);
                    $transparentColor = $this->hexColor($transparentColor);
                    $cmd = '-fill "'.$firstCol.'" -opaque "'.$transparentColor.'"';
                    $this->imageMagickExec($imgName, $imgName, $cmd);
                }
                if (@is_file($imgName))    {
                    // Accoring to the GM manual duplicated colors will be removed with -colors xxx seting
                    // However this does not happen. We first convert to TrueColor
                    // Then back to 256 colors, this will cleanup the palete for sure/
                    // R. van Twisk ries@vantwisk.nl
                    $this->imageMagickExec($imgName, $imgName, '-type TrueColor');
                    $this->imageMagickExec($imgName, $imgName, '-colors 256');
                    $tmpImg = $this->imageCreateFromFile($imgName);
                }
            } else    {
                $tmpImg = $img;
            }
            if ($tmpImg)    {
                $img = $tmpImg;
                if ($closest)    {
                    $retCol = ImageColorClosest ($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
                } else    {
                    $retCol = ImageColorExact ($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
                }
            }
                // unlink files from process
            if (!$this->dontUnlinkTempFiles)    {
                if ($imgName)    {
                        @unlink($imgName);
                }
            }
        }
        return $retCol;    
}