rtgx

Deformácie textu pomocou ImageMagick

Výsledkom je obrázok obsahujúci viac-menej náhodne zdeformovaný text; berte to prosím ako test možností programu ImageMagick, nie ako finálnu verziu, iste by bolo čo vylepšovať.

Typoscript setup

plugin.tx_rtgartnow_pi1 {
# text v obrazku
text = e-artnow
# pouzity TTF font
font = EXT:rtgartnow/res/Helvetica_Neue.ttf
# pomocny subor
fileTmp = EXT:rtgartnow/res/tmp.gif
# vystupny subor
fileOut = fileadmin/header.gif
}

PHP (extension frontend modul)

// Set absolute paths
$font = t3lib_div::getFileAbsFileName( trim( $this->conf['font'] ), FALSE );
$fileTmp = t3lib_div::getFileAbsFileName( trim( $this->conf['fileTmp'] ), FALSE );
$fileOut = t3lib_div::getFileAbsFileName( trim( $this->conf['fileOut'] ), FALSE );

// Deform text
$cmd = t3lib_div::imageMagickCommand( 'convert', '-size 463x -background white -fill black -font '.$font.' label:'.$this->conf['text'].' '.$fileTmp );
$ret = exec( $cmd );

$flip = mt_rand( 0, 1 ) == 1 ? ' -flip ' : ' ';
$cmd = t3lib_div::imageMagickCommand( 'convert', $fileTmp.' -resize 463x150! '.$flip.' '.$fileTmp );
$ret = exec( $cmd );

$wave1 = mt_rand( 4, 6 ).'x'.( rand( 6, 13 ) * 11 );
$wave2 = rand( 4, 6 ).'x'.( mt_rand( 6, 11 ) * 11 );
$rotate = time() % 2 > 0 ? '+' : '-';
$nrotate = $rotate == '+' ? '-' : '+';
$cmd = t3lib_div::imageMagickCommand( 'convert',
    $fileTmp.'
    -wave '.$wave1.'
    -swirl 13
    -rotate '.$rotate.'90
    -wave '.$wave2.'
    -swirl 13
    -rotate '.$nrotate.'90
    '.$flip.'
    -region 230x160+0+0 -swirl '.$nrotate.'65
    -region 230x160+115+0 -swirl '.$nrotate.'60
    -region 230x160+230+0 -swirl '.$rotate.'65
    -region 463x160+0+0 -sharpen 0x2
    '.$fileOut
);
$ret = exec( $cmd );

echo '<p><img id="imgLogo" src="'.$this->conf['fileOut'].'" alt="'.$this->conf['text'].'" title="'.$this->conf['text'].'" /></p>';

Výsledok

Text zdeformovaný softvérom ImageMagick
Text zdeformovaný softvérom ImageMagick
 
Typo3 extension Ext: rtgartnow 1.1.1, 75.3 (kB)