[TYPO3-dev] Over 2Million images rendering using GIFBUILDER (but not all at once...)
Ries van Twisk
typo3 at rvt.dds.nl
Fri Nov 6 04:20:01 CET 2009
Bart,
below is my version.
two modifications from the origional
1) It created sub directories for 3 levels
2) it increases the length of the generated md5 to 16 characters.
What is the reason you also overload the function imageMagickConvert,
and not the filename functions (mkdir, gifBuild and filename)?
Ries
<?php
require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
require_once(PATH_tslib.'class.tslib_gifbuilder.php');
class ux_tslib_gifbuilder extends tslib_gifbuilder {
/**
*
* @param <type> $theNewFolder
* @return <type> Added true to mkdir for recursive creation of
directories
*/
public function mkdir($theNewFolder) {
$theNewFolder = preg_replace('|/$|','',$theNewFolder);
if (!@is_dir($theNewFolder)) {
if (@mkdir($theNewFolder,
octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']), true)){
chmod($theNewFolder,
octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'])); //
added this line, because the mode at 'mkdir' has a strange behaviour
sometimes
if($GLOBALS['TYPO3_CONF_VARS']['BE']
['createGroup']) { // skip this if createGroup is empty
@chgrp($theNewFolder,
$GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
}
return true;
} else {
return false;
}
}
return true;
}
/**
* Initiates the image file generation if ->setup is true and if the
file did not exist already.
* Gets filename from fileName() and if file exists in typo3temp/ dir
it will - of course - not be rendered again.
* Otherwise rendering means calling ->make(), then ->output(), then -
>destroy()
*
* @return string The filename for the created GIF/PNG file. The
filename will be prefixed "GB_"
* @see make(), fileName()
*/
function gifBuild() {
if ($this->setup) {
$gifFileName = $this->fileName('GB/'); // Relative to PATH_site
if (!@file_exists($gifFileName)) { // File exists
// Create temporary directory if not done:
$dir=dirname($gifFileName);
$this->mkdir(PATH_site.$dir);
// Create file:
$this->make();
$this->output($gifFileName);
$this->destroy();
}
return $gifFileName;
}
}
/**
* Calculates the GIFBUILDER output filename/path based on a
serialized, hashed value of this->setup
*
* @param string Filename prefix, eg. "GB_"
* @return string The relative filepath (relative to PATH_site)
* @access private
*/
function fileName($pre) {
$filename=
($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'] ?
$GLOBALS['TSFE']->fileNameASCIIPrefix(implode('_',array_merge($this-
>combinedTextStrings,$this-
>combinedFileNames)),intval($GLOBALS['TSFE']->config['config']
['meaningfulTempFilePrefix']),'_') : '').
t3lib_div::shortMD5(serialize($this->setup),16).
'.'.$this->extension();
$l1=substr($filename,0,1);
$l2=substr($filename,1,1);
$l3=substr($filename,2,1);
return "{$this->tempPath}{$pre}{$l1}/{$l2}/{$l3}/
$filename";
}
}
?>
On Nov 5, 2009, at 9:36 PM, Bartosz Aninowski wrote:
>
>> the only solution I currently see is XCLASS tslib_gifbuilder,
>> am I over looking something? maby?
>
> Hi Ries
> Please check this out
> http://techblog.evo.pl/wp-content/uploads/2009/11/T3X_evo_massimages-0_0_0-z-200911060332.t3x
> If you find this ext usefull I will publish it in TER
>
>
> --
> Bartosz Aninowski
> typo(3)holics
> http://techblog.evo.pl/en/evo_nginx_boost-extension/ [Memcache Power
> for TYPO3]
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
regards, Ries van Twisk
-------------------------------------------------------------------------------------------------
tags: Freelance TYPO3 Glassfish JasperReports JasperETL Flex Blaze-DS
WebORB PostgreSQL DB-Architect
email: ries at vantwisk.nl web: http://www.rvantwisk.nl/
skype: callto://r.vantwisk
Phone: +1-810-476-4196 Cell: +593 9901 7694 SIP:
+1-747-690-5133
regards, Ries van Twisk
-------------------------------------------------------------------------------------------------
tags: Freelance TYPO3 Glassfish JasperReports JasperETL Flex Blaze-DS
WebORB PostgreSQL DB-Architect
email: ries at vantwisk.nl web: http://www.rvantwisk.nl/
skype: callto://r.vantwisk
Phone: +1-810-476-4196 Cell: +593 9901 7694 SIP:
+1-747-690-5133
More information about the TYPO3-dev
mailing list