Public Member Functions | |
| init () | |
| Initialize; reading parameters with GPvar and checking file path Results in internal var, $this->input, being set to the absolute path of the file for which to make the thumbnail. | |
| main () | |
| Create the thumbnail Will exit before return if all is well. | |
| errorGif ($l1, $l2, $l3) | |
| Creates error image based on gfx/notfound_thumb.png Requires GD lib enabled, otherwise it will exit with the three textstrings outputted as text. | |
| fontGif ($font) | |
| Creates a font-preview thumbnail. | |
| wrapFileName ($inputName) | |
| Wrapping the input filename in double-quotes. | |
Public Attributes | |
| $include_once = array() | |
| $outdir = 'typo3temp/' | |
| $output = '' | |
| $sizeDefault = '56x56' | |
| $imageList | |
| $input | |
| $file | |
| $size | |
|
||||||||||||||||
|
Creates error image based on gfx/notfound_thumb.png Requires GD lib enabled, otherwise it will exit with the three textstrings outputted as text. Outputs the image stream to browser and exits!
Definition at line 268 of file thumbs.php. References $TYPO3_CONF_VARS, and PATH_t3lib. 00268 {
00269 global $TYPO3_CONF_VARS;
00270
00271 if (!$TYPO3_CONF_VARS['GFX']['gdlib']) die($l1.' '.$l2.' '.$l3);
00272
00273 // Creates the basis for the error image
00274 if ($TYPO3_CONF_VARS['GFX']['gdlib_png']) {
00275 Header('Content-type: image/png');
00276 $im = imagecreatefrompng(PATH_t3lib.'gfx/notfound_thumb.png');
00277 } else {
00278 Header('Content-type: image/gif');
00279 $im = imagecreatefromgif(PATH_t3lib.'gfx/notfound_thumb.gif');
00280 }
00281 // Sets background color and print color.
00282 $white = ImageColorAllocate($im, 0,0,0);
00283 $black = ImageColorAllocate($im, 255,255,0);
00284
00285 // Prints the text strings with the build-in font functions of GD
00286 $x=0;
00287 $font=0;
00288 if ($l1) {
00289 imagefilledrectangle($im, $x, 9, 56, 16, $black);
00290 ImageString($im,$font,$x,9,$l1,$white);
00291 }
00292 if ($l2) {
00293 imagefilledrectangle($im, $x, 19, 56, 26, $black);
00294 ImageString($im,$font,$x,19,$l2,$white);
00295 }
00296 if ($l3) {
00297 imagefilledrectangle($im, $x, 29, 56, 36, $black);
00298 ImageString($im,$font,$x,29,substr($l3,-14),$white);
00299 }
00300
00301 // Outputting the image stream and exit
00302 if ($TYPO3_CONF_VARS['GFX']['gdlib_png']) {
00303 imagePng($im);
00304 } else {
00305 imageGif($im);
00306 }
00307 imagedestroy($im);
00308 exit;
00309 }
|
|
|
Creates a font-preview thumbnail. This means a PNG/GIF file with the text "AaBbCc...." set with the font-file given as input and in various sizes to show how the font looks Requires GD lib enabled. Outputs the image stream to browser and exits!
Definition at line 320 of file thumbs.php. References $TYPO3_CONF_VARS. 00320 {
00321 global $TYPO3_CONF_VARS;
00322
00323 if (!$TYPO3_CONF_VARS['GFX']['gdlib']) die('');
00324
00325 // Create image and set background color to white.
00326 $im = ImageCreate(250,76);
00327 $white = ImageColorAllocate($im, 255,255,255);
00328 $col = ImageColorAllocate($im, 0,0,0);
00329
00330 // The test string and offset in x-axis.
00331 $string = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÆæØøÅåÄäÖöÜüß';
00332 $x=13;
00333
00334 // Print (with non-ttf font) the size displayed
00335 imagestring ($im, 1, 0, 2, '10', $col);
00336 imagestring ($im, 1, 0, 15, '12', $col);
00337 imagestring ($im, 1, 0, 30, '14', $col);
00338 imagestring ($im, 1, 0, 47, '18', $col);
00339 imagestring ($im, 1, 0, 68, '24', $col);
00340
00341 // Print with ttf-font the test string
00342 imagettftext ($im, t3lib_div::freetypeDpiComp(10), 0, $x, 8, $col, $font, $string);
00343 imagettftext ($im, t3lib_div::freetypeDpiComp(12), 0, $x, 21, $col, $font, $string);
00344 imagettftext ($im, t3lib_div::freetypeDpiComp(14), 0, $x, 36, $col, $font, $string);
00345 imagettftext ($im, t3lib_div::freetypeDpiComp(18), 0, $x, 53, $col, $font, $string);
00346 imagettftext ($im, t3lib_div::freetypeDpiComp(24), 0, $x, 74, $col, $font, $string);
00347
00348 // Output PNG or GIF based on $TYPO3_CONF_VARS['GFX']['gdlib_png']
00349 if ($TYPO3_CONF_VARS['GFX']['gdlib_png']) {
00350 Header('Content-type: image/png');
00351 imagePng($im);
00352 } else {
00353 Header('Content-type: image/gif');
00354 imageGif($im);
00355 }
00356 imagedestroy($im);
00357 exit;
00358 }
|
|
|
Initialize; reading parameters with GPvar and checking file path Results in internal var, $this->input, being set to the absolute path of the file for which to make the thumbnail.
Definition at line 135 of file thumbs.php. References PATH_site. 00135 {
00136 global $TYPO3_CONF_VARS;
00137
00138 // Setting GPvars:
00139 $this->file = t3lib_div::_GP('file');
00140 $this->size = t3lib_div::_GP('size');
00141
00142 // Image extension list is set:
00143 $this->imageList = $TYPO3_CONF_VARS['GFX']['imagefile_ext']; // valid extensions. OBS: No spaces in the list, all lowercase...
00144
00145 // if the filereference $this->file is relative, we correct the path
00146 if (substr($this->file,0,3)=='../') {
00147 $this->input = PATH_site.ereg_replace('^\.\./','',$this->file);
00148 } else {
00149 $this->input = $this->file;
00150 }
00151
00152 // Now the path is absolute.
00153 // Checking for backpath and double slashes + the thumbnail can be made from files which are in the PATH_site OR the lockRootPath only!
00154 if (!t3lib_div::isAllowedAbsPath($this->input)) {
00155 $this->input='';
00156 }
00157 }
|
|
|
Create the thumbnail Will exit before return if all is well.
Definition at line 165 of file thumbs.php. References $TYPO3_CONF_VARS, and PATH_site. 00165 {
00166 global $TYPO3_CONF_VARS;
00167
00168 // If file exists, we make a thumbsnail of the file.
00169 if ($this->input && @file_exists($this->input)) {
00170
00171 // Check file extension:
00172 if (ereg('(.*)\.([^\.]*$)',$this->input,$reg)) {
00173 $ext=strtolower($reg[2]);
00174 $ext=($ext=='jpeg')?'jpg':$ext;
00175 if ($ext=='ttf') {
00176 $this->fontGif($this->input); // Make font preview... (will not return)
00177 } elseif (!t3lib_div::inList($this->imageList, $ext)) {
00178 $this->errorGif('Not imagefile!',$ext,$this->input);
00179 }
00180 } else {
00181 $this->errorGif('Not imagefile!','No ext!',$this->input);
00182 }
00183
00184 // ... so we passed the extension test meaning that we are going to make a thumbnail here:
00185 $this->size = $this->size ? $this->size : $this->sizeDefault; // default
00186
00187 //I added extra check, so that the size input option could not be fooled to pass other values. That means the value is exploded, evaluated to an integer and the imploded to [value]x[value]. Furthermore you can specify: size=340 and it'll be translated to 340x340.
00188 $sizeParts = explode('x', $this->size.'x'.$this->size); // explodes the input size (and if no "x" is found this will add size again so it is the same for both dimensions)
00189 $sizeParts = array(t3lib_div::intInRange($sizeParts[0],1,1000),t3lib_div::intInRange($sizeParts[1],1,1000)); // Cleaning it up, only two parameters now.
00190 $this->size = implode('x',$sizeParts); // Imploding the cleaned size-value back to the internal variable
00191 $sizeMax = max($sizeParts); // Getting max value
00192
00193 // Init
00194 $mtime = filemtime($this->input);
00195 $outpath = PATH_site.$this->outdir;
00196
00197 // Should be - ? 'png' : 'gif' - , but doesn't work (ImageMagick prob.?)
00198 // René: png work for me
00199 $thmMode = t3lib_div::intInRange($TYPO3_CONF_VARS['GFX']['thumbnails_png'],0);
00200 $outext = ($ext!='jpg' || ($thmMode & 2)) ? ($thmMode & 1 ? 'png' : 'gif') : 'jpg';
00201
00202 $outfile = 'tmb_'.substr(md5($this->input.$mtime.$this->size),0,10).'.'.$outext;
00203 $this->output = $outpath.$outfile;
00204
00205 if ($TYPO3_CONF_VARS['GFX']['im']) {
00206 // If thumbnail does not exist, we generate it
00207 if (!@file_exists($this->output)) {
00208 /* if (strstr($this->input,' ') || strstr($this->output,' ')) {
00209 $this->errorGif('Spaces in','filepath',$this->input);
00210 }
00211 */ // 16 colors for small (56) thumbs, 64 for bigger and all for jpegs
00212 if ($outext=='jpg') {
00213 $colors = '';
00214 } else {
00215 $colors = ($sizeMax>56)?'-colors 64':'-colors 16';
00216 }
00217 $cmd = ($TYPO3_CONF_VARS['GFX']['im_path_lzw'] ? $TYPO3_CONF_VARS['GFX']['im_path_lzw'] : $TYPO3_CONF_VARS['GFX']['im_path']).
00218 'convert -sample '.$this->size.' '.$colors.' '.$this->wrapFileName($this->input.'[0]').' '.$this->wrapFileName($this->output);
00219
00220 // echo $cmd;
00221 exec($cmd);
00222 if (!@file_exists($this->output)) {
00223 $this->errorGif('No thumb','generated!',$this->input);
00224 }
00225 }
00226 // The thumbnail is read and output to the browser
00227 if($fd = @fopen($this->output,'rb')) {
00228 Header('Content-type: image/'.$outext);
00229 while (!feof($fd)) {
00230 echo fread( $fd, 10000 );
00231 }
00232 fclose( $fd );
00233 } else {
00234 $this->errorGif('Read problem!','',$this->output);
00235 }
00236 } else exit;
00237 } else {
00238 $this->errorGif('No valid','inputfile!',$this->input);
00239 }
00240 }
|
|
|
Wrapping the input filename in double-quotes.
Definition at line 367 of file thumbs.php. 00367 {
00368 if (strstr($inputName,' ')) {
00369 $inputName='"'.$inputName.'"';
00370 }
00371 return $inputName;
00372 }
|
|
|
Definition at line 125 of file thumbs.php. |
|
|
Definition at line 121 of file thumbs.php. |
|
|
Definition at line 115 of file thumbs.php. |
|
|
Definition at line 122 of file thumbs.php. |
|
|
Definition at line 117 of file thumbs.php. |
|
|
Definition at line 118 of file thumbs.php. |
|
|
Definition at line 126 of file thumbs.php. |
|
|
Definition at line 119 of file thumbs.php. |
1.3.8-20040913