[TYPO3-english] Gifbuilder

StephenBungert stephenbungert at yahoo.de
Thu Oct 9 14:40:49 CEST 2008


Does gif builder convert whatever source images it uses first to a gif,
before then saving it in the 'format' specified?

Fort a site I'm making, all tt_news images must have grey borders with round
corners.

To achieve this I have used an image processing script like the one below.
It does everything I need. It sizes the images and makes a greyborder with
round corners, and within the border is the article's image. What it also
does it make the outputed image look shite.

It must be a something gifbuilder is doing to the image before saving as
png. Is there anyway that I can do this without the image quality being
ruined? Is there away maybe of combining the original image with a
gifbuilder image (of the border and mask) rather then making teh original
also a part of the gifbuilder?

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 1999-2004 Kasper Skaarhoj (kasper at typo3.com)
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the
license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

function user_fmfV2ImageProcessor($paramArray, $conf) {
	$markerArray = $paramArray[0];
	$lConf = $paramArray[1];
    $pObj = &$conf['parentObj']; // make a reference to the parent-object
	$row = $pObj->local_cObj->data;
	
	$picWidthList		= '147';
	$picHeightList		= $picWidthList;
	$picWidthLatest		= '469';
	$picHeightLatest	= '314';
	$picFilePath		= 'uploads/pics/';
	$picBasePath		= 'fileadmin/templates/fmf/v2/images/';
	
	$imageNum = isset($lConf['imageCount']) ? $lConf['imageCount']:1;
	$imageNum = t3lib_div::intInRange($imageNum, 0, 100);
	$theImgCode = '';
	$imgs = t3lib_div::trimExplode(',', $row['image'], 1);
	$imgsCaptions = explode(chr(10), $row['imagecaption']);
	$imgsAltTexts = explode(chr(10), $row['imagealttext']);
	$imgsTitleTexts = explode(chr(10), $row['imagetitletext']);

	reset($imgs);

	$cc = 0;
	
	$whatToDisplay =
$pObj->cObj->data['pi_flexform']['data']['sDEF']['lDEF']['what_to_display']['vDEF'];
	
// Not tested with multiple image articles
	if ($whatToDisplay == 'SINGLE') {
		// remove first img from the image array in single view if the TSvar
firstImageIsPreview is set
		if ((	(count($imgs) > 1 && $pObj->config['firstImageIsPreview']) ||
(count($imgs) >= 1 && $pObj->config['forceFirstImageIsPreview']))) {
			array_shift($imgs);
			array_shift($imgsCaptions);
			array_shift($imgsAltTexts);
			array_shift($imgsTitleTexts);
		}
		
		// get img array parts for single view pages
		if ($pObj->piVars[$pObj->config['singleViewPointerName']]) {
			$spage = $pObj->piVars[$pObj->config['singleViewPointerName']];
			$astart = $imageNum*$spage;
			$imgs = array_slice($imgs,$astart,$imageNum);
			$imgsCaptions = array_slice($imgsCaptions,$astart,$imageNum);
			$imgsAltTexts = array_slice($imgsAltTexts,$astart,$imageNum);
			$imgsTitleTexts = array_slice($imgsTitleTexts,$astart,$imageNum);
		}
		
		// Still to do...
		// SINGLE page articles don't have images in V2. May need to later handle
images for SINGLE if this changes.
	}
	
	if ($whatToDisplay == 'LIST' || $whatToDisplay == 'SEARCH') {
		while (list(, $val) = each($imgs)) {
			if ($cc == $imageNum) break;
			if ($val) {
				$lConf['image.']['file']				= 'GIFBUILDER';
				$lConf['image.']['file.']['XY']			= $picWidthList . ',' .
$picHeightList;
				$lConf['image.']['file.']['format']		= 'jpg';
				$lConf['image.']['file.']['quality']	= '80';
				
				$lConf['image.']['file.']['10']						= 'IMAGE';
				$lConf['image.']['file.']['10.']['file']			= $picFilePath . $val;
				$lConf['image.']['file.']['10.']['file.']['minW']	= $picWidthList;
				$lConf['image.']['file.']['10.']['file.']['minH']	= $picHeightList;
				$lConf['image.']['file.']['10.']['file.']['XY']		= $picWidthList . ',' .
$picHeightList;
				$lConf['image.']['file.']['10.']['file.']['width']	= $picWidthList .
'c';
				$lConf['image.']['file.']['10.']['file.']['height']	= $picHeightList .
'c';
				
				$lConf['image.']['file.']['20']						= 'IMAGE';
				$lConf['image.']['file.']['20.']['file']			= $picBasePath .
'art_small.gif';
				$lConf['image.']['file.']['20.']['file.']['minW']	= $picWidthList;
				$lConf['image.']['file.']['20.']['file.']['minH']	= $picHeightList;
				$lConf['image.']['file.']['20.']['file.']['XY']		= $picWidthList . ',' .
$picHeightList;
				$lConf['image.']['file.']['20.']['file.']['width']	= $picWidthList .
'c';
				$lConf['image.']['file.']['20.']['file.']['height']	= $picHeightList .
'c';
				
				$lConf['image.']['file.']['20.']['mask']			= $picBasePath .
'art_small_mask3.gif';
				$lConf['image.']['file.']['20.']['mask.']['minW']	= $picWidthList;
				$lConf['image.']['file.']['20.']['mask.']['minH']	= $picHeightList;
				$lConf['image.']['file.']['20.']['mask.']['XY']		= $picWidthList . ',' .
$picHeightList;
				$lConf['image.']['file.']['20.']['mask.']['width']	= $picWidthList .
'c';
				$lConf['image.']['file.']['20.']['mask.']['height']	= $picHeightList .
'c';
				
				$lConf['image.']['altText']		= $imgsAltTexts[$cc];
				$lConf['image.']['titleText']	= $imgsTitleTexts[$cc];
			}
			$theImgCode .= $pObj->local_cObj->IMAGE($lConf['image.']) .
$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
			$cc++;
			unset($imgs[0]);
		}
	} else if ($whatToDisplay == 'LATEST') {
		while (list(, $val) = each($imgs)) {
			if ($cc == $imageNum) break;
			if ($val) {
				$lConf['image.']['file']				= 'GIFBUILDER';
				$lConf['image.']['file.']['XY']			= $picWidthLatest . ',' .
$picHeightLatest;
				$lConf['image.']['file.']['format']		= 'jpg';
				$lConf['image.']['file.']['quality']	= '80';
				
				$lConf['image.']['file.']['10']						= 'IMAGE';
				$lConf['image.']['file.']['10.']['file']			= $picFilePath . $val;
				$lConf['image.']['file.']['10.']['file.']['minW']	= $picWidthLatest;
				$lConf['image.']['file.']['10.']['file.']['minH']	= $picHeightLatest;
				$lConf['image.']['file.']['10.']['file.']['XY']		= $picWidthLatest . ','
. $picHeightLatest;
				$lConf['image.']['file.']['10.']['file.']['width']	= $picWidthLatest .
'c';
				$lConf['image.']['file.']['10.']['file.']['height']	= $picHeightLatest .
'c';
				
				$lConf['image.']['file.']['20']						= 'IMAGE';
				$lConf['image.']['file.']['20.']['file']			= $picBasePath .
'art_large.jpg';
				$lConf['image.']['file.']['20.']['file.']['minW']	= $picWidthLatest;
				$lConf['image.']['file.']['20.']['file.']['minH']	= $picHeightLatest;
				$lConf['image.']['file.']['20.']['file.']['XY']		= $picWidthLatest . ','
. $picHeightLatest;
				$lConf['image.']['file.']['20.']['file.']['width']	= $picWidthLatest .
'c';
				$lConf['image.']['file.']['20.']['file.']['height']	= $picHeightLatest .
'c';
				
				$lConf['image.']['file.']['20.']['mask']			= $picBasePath .
'article_large_mask3.png';
				$lConf['image.']['file.']['20.']['mask.']['minW']	= $picWidthLatest;
				$lConf['image.']['file.']['20.']['mask.']['minH']	= $picHeightLatest;
				$lConf['image.']['file.']['20.']['mask.']['XY']		= $picWidthLatest . ','
. $picHeightLatest;
				$lConf['image.']['file.']['20.']['mask.']['width']	= $picWidthLatest .
'c';
				$lConf['image.']['file.']['20.']['mask.']['height']	= $picHeightLatest .
'c';
				
				$lConf['image.']['altText']		= $imgsAltTexts[$cc];
				$lConf['image.']['titleText']	= $imgsTitleTexts[$cc];
			}
			$theImgCode .= $pObj->local_cObj->IMAGE($lConf['image.']) .
$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
			$cc++;
			unset($imgs[0]);
		}
	}
	
	$markerArray['###NEWS_IMAGE###'] = '';
	
	if ($cc) {
		$markerArray['###NEWS_IMAGE###'] =
$pObj->local_cObj->wrap(trim($theImgCode), $lConf['imageWrapIfAny']);
	} else {
		$markerArray['###NEWS_IMAGE###'] =
$pObj->local_cObj->stdWrap($markerArray['###NEWS_IMAGE###'],$lConf['image.']['noImage_stdWrap.']);
	}
	
	return $markerArray;
}
?>

-----
-- 
Stephen Bungert
-- 
View this message in context: http://www.nabble.com/Gifbuilder-tp19898169p19898169.html
Sent from the TYPO3 English mailing list archive at Nabble.com.



More information about the TYPO3-english mailing list