Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezimagegdhandler.php
Go to the documentation of this file.
1 <?php
23 class eZImageGDHandler extends eZImageHandler
24 {
25 public function __construct( $handlerName, $isGloballyEnabled,
26 $outputRewriteType = self::REPLACE_SUFFIX,
27 $conversionRules = false )
28 {
29 $supportedInputMIMETypes = array();
30 $supportedOutputMIMETypes = array();
31 $this->InputMap = array();
32 $this->OutputMap = array();
33 $this->OutputQualityMap = array();
34 $isEnabled = false;
35 if ( function_exists( "imagetypes" ) )
36 {
37 $gdFunctions = array( array( 'mimetype' => 'image/gif',
38 'input' => 'imagecreatefromgif',
39 'output' => 'imagegif' ),
40 array( 'mimetype' => 'image/vnd.wap.wbmp',
41 'input' => 'imagecreatefromwbmp',
42 'output' => 'imagewbmp' ),
43 array( 'mimetype' => 'image/png',
44 'input' => 'imagecreatefrompng',
45 'output' => 'imagepng' ),
46 array( 'mimetype' => 'image/jpeg',
47 'input' => 'imagecreatefromjpeg',
48 'output' => 'imagejpeg',
49 'qualityparameter' => true ) );
50 foreach ( $gdFunctions as $gdFunction )
51 {
52 $inputFunction = $gdFunction['input'];
53 $outputFunction = $gdFunction['output'];
54 if ( function_exists( $inputFunction ) or function_exists( $outputFunction ) )
55 {
56 $isEnabled = true;
57 $mimeType = $gdFunction['mimetype'];
58 if ( function_exists( $inputFunction ) )
59 {
60 $supportedInputMIMETypes[] = $mimeType;
61 $this->InputMap[$mimeType] = $inputFunction;
62 }
63 if ( function_exists( $outputFunction ) )
64 {
65 $this->OutputMap[$mimeType] = $outputFunction;
66 $supportedOutputMIMETypes[] = $mimeType;
67 }
68 if ( isset( $gdFunction['qualityparameter'] ) )
69 $this->OutputQualityMap[$mimeType] = $gdFunction['qualityparameter'];
70 else
71 $this->OutputQualityMap[$mimeType] = false;
72 }
73 }
74 }
75 if ( !$isGloballyEnabled )
76 $isEnabled = false;
77 $this->FilterFunctionMap = array( 'geometry/scale' => 'scaleImage',
78 'geometry/scalewidth' => 'scaleImageWidth',
79 'geometry/scaleheight' => 'scaleImageHeight',
80 'geometry/scaledownonly' => 'scaleImageDownOnly',
81 'geometry/scalewidthdownonly' => 'scaleImageWidthDownOnly',
82 'geometry/scaleheightdownonly' => 'scaleImageHeightDownOnly',
83 'geometry/scaleexact' => 'scaleImageExact',
84 'geometry/scalepercent' => 'scaleImagePercent',
85 'geometry/crop' => 'cropImage',
86 'colorspace/gray' => 'setImageColorspaceGray',
87 'luminance' => 'setImageLuminance',
88 'luminance/gray' => 'setImageLuminanceNamed',
89 'luminance/sepia' => 'setImageLuminanceNamed',
90 'color/monochrome' => 'setImageColorThresholdName',
91 'border' => 'createImageBorder',
92 'border/color' => 'setImageBorderColor',
93 'border/width' => 'setImageBorderWidth' );
94 $this->LuminanceColorScales = array( 'luminance/gray' => array( 1.0, 1.0, 1.0 ),
95 'luminance/sepia' => array( 1.0, 0.89, 0.74 ) );
96 $this->ThresholdList = array( 'color/monochrome' => array( array( 'threshold' => 127,
97 'rgb' => array( 0, 0, 0 ) ),
98 array( 'threshold' => 255,
99 'rgb' => array( 255, 255, 255 ) ) ) );
100
101 $filters = array();
102 foreach ( $this->FilterFunctionMap as $filterName => $filterFunction )
103 {
104 $filters[] = array( 'name' => $filterName );
105 }
106 parent::__construct(
107 $handlerName,
108 $isEnabled,
109 $outputRewriteType,
110 $supportedInputMIMETypes,
111 $supportedOutputMIMETypes,
112 $conversionRules,
113 $filters
114 );
115 }
116
120 function convert( $manager, $sourceMimeData, &$destinationMimeData, $filters = false )
121 {
122 $sourceMimeType = $sourceMimeData['name'];
123 $destinationMimeType = $destinationMimeData['name'];
124 if ( !isset( $this->InputMap[$sourceMimeType] ) )
125 {
126 eZDebug::writeError( "MIME-Type $sourceMimeType is not supported as input by GD converter", __METHOD__ );
127 return false;
128 }
129 if ( !isset( $this->OutputMap[$destinationMimeType] ) )
130 {
131 eZDebug::writeError( "MIME-Type $destinationMimeType is not supported as output by GD converter", __METHOD__ );
132 return false;
133 }
134
135 $inputFunction = $this->InputMap[$sourceMimeType];
136 $outputFunction = $this->OutputMap[$destinationMimeType];
137 $outputQualityParameter = $this->OutputQualityMap[$destinationMimeType];
138 $inputFile = $sourceMimeData['url'];
139 $outputFile = $destinationMimeData['url'];
140
141 if ( !file_exists( $inputFile ) )
142 {
143 eZDebug::writeError( "Source image $inputFile does not exist, cannot convert", __METHOD__ );
144 return false;
145 }
146
147 $currentImage = $inputFunction( $inputFile );
148
149
150 // ###PHP8PATCH check if imagefile could be loaded if not write error
151 if ( !is_object( $currentImage ) )
152 {
153 eZDebug::writeError( "Source image $inputFile can not be load with function: $inputFunction ( inputFile )", __METHOD__ );
154 return false;
155 }
156
157 $filterVariables = array( 'border-color' => array( 127, 127, 127 ),
158 'border-size' => array( 0, 0 ) );
159
160 if ( $filters !== false )
161 {
162 foreach ( $filters as $filterData )
163 {
164 $filterName = $filterData['name'];
165 if ( isset( $this->FilterFunctionMap[$filterName] ) )
166 {
167 $filterFunction = $this->FilterFunctionMap[$filterName];
168 $filteredImage = $this->$filterFunction( $currentImage, $filterData, $filterVariables, $sourceMimeData, $destinationMimeData );
169 if ( $filteredImage !== false )
170 {
171 if ( $filteredImage != $currentImage )
172 {
173 ImageDestroy( $currentImage );
174 }
175 $currentImage = $filteredImage;
176 }
177 }
178 }
179 }
180
181 $outputImage = $currentImage;
182
183 if ( $outputImage )
184 {
185 $outputQuality = false;
186 if ( $outputQualityParameter )
187 $outputQuality = $manager->qualityValue( $destinationMimeType );
188 if ( $outputQuality !== false )
189 {
190 $returnCode = $outputFunction( $outputImage, $outputFile, $outputQuality );
191 }
192 else
193 {
194 $returnCode = $outputFunction( $outputImage, $outputFile );
195 }
196
197 ImageDestroy( $outputImage );
198 }
199 else
200 $returnCode = false;
201
202 if ( $returnCode )
203 {
204 if ( !file_exists( $destinationMimeData['url'] ) )
205 {
206 eZDebug::writeError( "Unknown destination file: " . $destinationMimeData['url'], "eZImageGDHandler(" . $this->HandlerName . ")" );
207 return false;
208 }
209 $this->changeFilePermissions( $destinationMimeData['url'] );
210 return true;
211 }
212 else
213 {
214 eZDebug::writeWarning( "Failed converting $inputFile ($sourceMimeType) to $outputFile ($destinationMimeType)", __METHOD__ );
215 return false;
216 }
217 }
218
219 static function setImageBorderColor( &$imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
220 {
221 $filterVariables['border-color'] = $filterData['data'];
222 return false;
223 }
224
225 function setImageBorderWidth( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
226 {
227 $filterVariables['border-size'] = array( $filterData['data'][0], $filterData['data'][0] );
228 return $this->createImageBorder( $imageObject, $filterData, $filterVariables, $sourceMimeData, $destinationMimeData );
229 }
230
231 function setImageBorder( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
232 {
233 $filterVariables['border-size'] = array( $filterData['data'][0], $filterData['data'][1] );
234 return $this->createImageBorder( $imageObject, $filterData, $filterVariables, $sourceMimeData, $destinationMimeData );
235 }
236
237 function createImageBorder( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
238 {
239 $width = ImageSX( $imageObject );
240 $height = ImageSY( $imageObject );
241 $borderWidth = $filterVariables['border-size'][0];
242 $borderHeight = $filterVariables['border-size'][1];
243 $borderColor = $filterVariables['border-color'];
244 $newWidth = $width + $borderWidth*2;
245 $newHeight = $height + $borderHeight*2;
246
247 $temporaryImageObject = $this->imageCopy( $imageObject,
248 $this->createGeometry( $newWidth, $newHeight, $borderWidth, $borderHeight ),
249 $this->createGeometry( $width, $height, 0, 0 ),
250 $sourceMimeData, $destinationMimeData );
251 $color = ImageColorAllocate( $temporaryImageObject, $borderColor[0], $borderColor[1], $borderColor[2] );
252 ImageFilledRectangle( $temporaryImageObject, 0, 0, $newWidth, $borderHeight, $color );
253 ImageFilledRectangle( $temporaryImageObject, $newWidth - $borderWidth, 0, $newWidth, $newHeight, $color );
254 ImageFilledRectangle( $temporaryImageObject, 0, $newHeight - $borderHeight, $newWidth, $newHeight, $color );
255 ImageFilledRectangle( $temporaryImageObject, 0, 0, $borderWidth, $newHeight, $color );
256 return $temporaryImageObject;
257 }
258
262 function setImageColorspaceGray( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
263 {
264 $colorScale = array( 1.0, 1.0, 1.0 );
265 return $this->setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
266 $colorScale );
267 }
268
273 function setImageLuminance( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
274 {
275 $colorScale = $filterData['data'];
276 return $this->setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
277 $colorScale );
278 }
279
284 function setImageLuminanceNamed( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
285 {
286 if ( isset( $this->LuminanceColorScales[$filterData['name']] ) )
287 {
288 $colorScale = $this->LuminanceColorScales[$filterData['name']];
289 }
290 else
291 {
292 eZDebug::writeDebug( "No luminance scale named " . $filterData['name'] . ", applying gray scales", __METHOD__ );
293 $colorScale = array( 1.0, 1.0, 1.0 );
294 }
295 return $this->setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
296 $colorScale );
297 }
298
303 function setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
304 $colorScale )
305 {
306 $white = ImageColorAllocate( $imageObject, 255, 255, 255 );
307 $black = ImageColorAllocate( $imageObject, 0, 0, 0 );
308
309 $rmod = $colorScale[0];
310 $gmod = $colorScale[1];
311 $bmod = $colorScale[2];
312
313 $width = ImageSX( $imageObject );
314 $height = ImageSY( $imageObject );
315 for ( $y = 0; $y < $height; ++$y )
316 {
317 for ( $x = 0; $x < $width; ++$x )
318 {
319 $rgb = ImageColorAt( $imageObject, $x, $y );
320
321 $r = ( $rgb >> 16 ) & 0xff;
322 $g = ( $rgb >> 8 ) & 0x0ff;
323 $b = ( $rgb ) & 0x0ff;
324
325 $luminance = ( $r * 0.3 ) + ( $g * 0.59 ) + ( $b * 0.11 );
326
327 $r = $luminance * $rmod;
328 $g = $luminance * $gmod;
329 $b = $luminance * $bmod;
330
331 $color = ImageColorAllocate( $imageObject, $r, $g, $b );
332
333 ImageSetPixel( $imageObject, $x, $y, $color );
334 }
335 }
336 return $imageObject;
337 }
338
343 function setImageColorThresholdName( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
344 {
345 if ( isset( $this->ThresholdList[$filterData['name']] ) )
346 {
347 $thresholdList = $this->ThresholdList[$filterData['name']];
348 }
349 else
350 {
351 eZDebug::writeDebug( "No threshold values named " . $filterData['name'] . ", applying black/white (monochrome) threshold", __METHOD__ );
352 $thresholdList = array( array( 'threshold' => 127,
353 'rgb' => array( 0, 0, 0 ) ),
354 array( 'threshold' => 255,
355 'rgb' => array( 255, 255, 255 ) ) );
356 }
357 return $this->setImageColorThreshold( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
358 $thresholdList );
359 }
360
365 static function setImageColorThreshold( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
366 $thresholdList )
367 {
368 foreach ( array_keys( $thresholdList ) as $thresholdKey )
369 {
370 $thresholdList[$thresholdKey]['color'] = ImageColorAllocate( $imageObject, $thresholdItem['rgb'][0], $thresholdItem['rgb'][1], $thresholdItem['rgb'][2] );
371 }
372 $defaultColor = $thresholdList[count( $thresholdList ) - 1]['color'];
373
374 $width = ImageSX( $imageObject );
375 $height = ImageSY( $imageObject );
376 for ( $y = 0; $y < $height; ++$y )
377 {
378 for ( $x = 0; $x < $width; ++$x )
379 {
380 $rgb = ImageColorAt( $imageObject, $x, $y );
381
382 $r = ( $rgb >> 16 ) & 0xff;
383 $g = ( $rgb >> 8 ) & 0x0ff;
384 $b = ( $rgb ) & 0x0ff;
385
386 $luminance = ( $r * 0.3 ) + ( $g * 0.59 ) + ( $b * 0.11 );
387
388 $color = false;
389 foreach ( $thresholdList as $thresholdItem )
390 {
391 if ( $luminance <= $thresholdItem['threshold'] )
392 {
393 $color = $thresholdItem['color'];
394 break;
395 }
396 }
397 if ( $color === false )
398 $color = $defaultColor;
399
400 ImageSetPixel( $imageObject, $x, $y, $color );
401 }
402 }
403 return $imageObject;
404 }
405
409 function cropImage( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
410 {
411 $width = $filterData['data'][0];
412 $height = $filterData['data'][1];
413 $x = $filterData['data'][2];
414 $y = $filterData['data'][3];
415 $imageWidth = ImageSX( $imageObject );
416 $imageHeight = ImageSY( $imageObject );
417 $width = max( min( $width, $imageWidth - $x ), 0 );
418 $height = max( min( $height, $imageHeight - $y ), 0 );
419 $destinationGeometry = $this->createGeometry( $width, $height, 0, 0 );
420 $geometry = $this->createGeometry( $width, $height, $x, $y );
421 return $this->imageCopy( $imageObject,
422 $destinationGeometry,
423 $geometry,
424 $sourceMimeData, $destinationMimeData );
425 }
426
432 function scaleImage( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
433 {
434 $geometry = $this->calculateScaledAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
435 $filterData['data'][0], $filterData['data'][1], true );
436 return $this->scaleImageCopy( $imageObject,
437 $geometry,
438 $sourceMimeData, $destinationMimeData );
439 }
440
447 function scaleImageDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
448 {
449 $geometry = $this->calculateScaledAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
450 $filterData['data'][0], $filterData['data'][1], false );
451 return $this->scaleImageCopy( $imageObject,
452 $geometry,
453 $sourceMimeData, $destinationMimeData );
454 }
455
461 function scaleImageWidth( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
462 {
463 $geometry = $this->calculateFixedWidthAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
464 $filterData['data'][0], true );
465 return $this->scaleImageCopy( $imageObject,
466 $geometry,
467 $sourceMimeData, $destinationMimeData );
468 }
469
475 function scaleImageHeight( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
476 {
477 $geometry = $this->calculateFixedHeightAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
478 $filterData['data'][0], true );
479 return $this->scaleImageCopy( $imageObject,
480 $geometry,
481 $sourceMimeData, $destinationMimeData );
482 }
483
490 function scaleImageWidthDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
491 {
492 $geometry = $this->calculateFixedWidthAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
493 $filterData['data'][0], false );
494 return $this->scaleImageCopy( $imageObject,
495 $geometry,
496 $sourceMimeData, $destinationMimeData );
497 }
498
505 function scaleImageHeightDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
506 {
507 $geometry = $this->calculateFixedHeightAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
508 $filterData['data'][0], false );
509 return $this->scaleImageCopy( $imageObject,
510 $geometry,
511 $sourceMimeData, $destinationMimeData );
512 }
513
517 function scaleImageExact( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
518 {
519 return $this->scaleImageCopy( $imageObject,
520 $this->createGeometry( $filterData['data'][0], $filterData['data'][1] ),
521 $sourceMimeData, $destinationMimeData );
522 }
523
527 function scaleImagePercent( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData )
528 {
529 $geometry = $this->calculateScaledPercentAspectGeometry( ImageSX( $imageObject ), ImageSY( $imageObject ),
530 $filterData['data'][0] / 100.0, $filterData['data'][1] / 100.0, true );
531 return $this->scaleImageCopy( $imageObject,
532 $geometry,
533 $sourceMimeData, $destinationMimeData );
534 }
535
542 function calculateScaledAspectGeometry( $sourceWidth, $sourceHeight,
543 $destinationWidth, $destinationHeight,
544 $allowUpScale )
545 {
546 $widthScale = $sourceWidth / $destinationWidth;
547 $heightScale = $sourceHeight / $destinationHeight;
548
549 $scale = $heightScale;
550 if ( $heightScale != $widthScale )
551 $scale = max( $heightScale, $widthScale );
552
553 if ( $scale < 1.0 and !$allowUpScale )
554 {
555 $destinationWidth = $sourceWidth;
556 $destinationHeight = $sourceHeight;
557 }
558 else
559 {
560 $destinationWidth = (int) ( $sourceWidth / $scale );
561 $destinationHeight = (int) ( $sourceHeight / $scale );
562 }
563 return $this->createGeometry( $destinationWidth, $destinationHeight );
564 }
565
573 function calculateScaledPercentAspectGeometry( $sourceWidth, $sourceHeight,
574 $destinationWidthPercent, $destinationHeightPercent,
575 $allowUpScale )
576 {
577 $destinationWidth = $sourceWidth * $destinationWidthPercent;
578 $destinationHeight = $sourceHeight * $destinationHeightPercent;
579 return $this->calculateScaledAspectGeometry( $sourceWidth, $sourceHeight,
580 $destinationWidth, $destinationHeight,
581 $allowUpScale );
582 }
583
590 function calculateFixedWidthAspectGeometry( $sourceWidth, $sourceHeight,
591 $destinationWidth,
592 $allowUpScale )
593 {
594 $scale = $sourceWidth / $destinationWidth;
595
596 if ( $scale < 1.0 and !$allowUpScale )
597 {
598 $destinationWidth = $sourceWidth;
599 $destinationHeight = $sourceHeight;
600 }
601 else
602 {
603 $destinationWidth = (int) ( $sourceWidth / $scale );
604 $destinationHeight = (int) ( $sourceHeight / $scale );
605 }
606 return $this->createGeometry( $destinationWidth, $destinationHeight );
607 }
608
615 function calculateFixedHeightAspectGeometry( $sourceWidth, $sourceHeight,
616 $destinationHeight,
617 $allowUpScale )
618 {
619 $scale = $sourceHeight / $destinationHeight;
620
621 if ( $scale < 1.0 and !$allowUpScale )
622 {
623 $destinationWidth = $sourceWidth;
624 $destinationHeight = $sourceHeight;
625 }
626 else
627 {
628 $destinationWidth = (int) ( $sourceWidth / $scale );
629 $destinationHeight = (int) ( $sourceHeight / $scale );
630 }
631 return $this->createGeometry( $destinationWidth, $destinationHeight );
632 }
633
637 static function scaleImageCopy( $imageObject,
638 $geometry,
639 $sourceMimeData, $destinationMimeData )
640 {
641 $destinationWidth = $geometry['width'];
642 $destinationHeight = $geometry['height'];
643 $sourceWidth = ImageSX( $imageObject );
644 $sourceHeight = ImageSY( $imageObject );
645
646 $temporaryImageObject = eZImageGDHandler::imageCreate( $destinationWidth, $destinationHeight, eZImageGDHandler::isImageTrueColor( $imageObject, $sourceMimeData ) );
647 imagealphablending( $temporaryImageObject, false );
648 imagesavealpha( $temporaryImageObject, true );
649 ImageCopyResampled( $temporaryImageObject, $imageObject,
650 0, 0, 0, 0,
651 $destinationWidth, $destinationHeight, $sourceWidth, $sourceHeight );
652 return $temporaryImageObject;
653 }
654
658 static function imageCopy( $imageObject, $destinationGeometry, $sourceGeometry,
659 $sourceMimeData, $destinationMimeData )
660 {
661 $destinationWidth = $destinationGeometry['width'];
662 $destinationHeight = $destinationGeometry['height'];
663
664 $temporaryImageObject = eZImageGDHandler::imageCreate( $destinationWidth, $destinationHeight, eZImageGDHandler::isImageTrueColor( $imageObject, $sourceMimeData ) );
665 ImageCopy( $temporaryImageObject, $imageObject,
666 $destinationGeometry['x'], $destinationGeometry['y'],
667 $sourceGeometry['x'], $sourceGeometry['y'], $sourceGeometry['width'], $sourceGeometry['height'] );
668 return $temporaryImageObject;
669 }
670
675 static function isImageTrueColor( &$imageObject, $mimeData )
676 {
677 return ImageIsTrueColor( $imageObject );
678 }
679
684 static function imageCreate( $width, $height, $isTrueColor = true )
685 {
686 if ( $isTrueColor )
687 return ImageCreateTrueColor( $width, $height );
688 else
689 return ImageCreate( $width, $height );
690 }
691
695 static function createGeometry( $width, $height, $x = 0, $y = 0 )
696 {
697 return array( 'x' => $x,
698 'y' => $y,
699 'width' => $width,
700 'height' => $height );
701 }
702
708 static function createFromINI( $iniGroup, $iniFilename = false )
709 {
710 if ( !$iniFilename )
711 $iniFilename = 'image.ini';
712
713 $handler = false;
714 $ini = eZINI::instance( $iniFilename );
715 if ( !$ini )
716 {
717 eZDebug::writeError( "Failed loading ini file $iniFilename", __METHOD__ );
718 return $handler;
719 }
720
721 if ( $ini->hasGroup( $iniGroup ) )
722 {
723 $name = $iniGroup;
724 if ( $ini->hasVariable( $iniGroup, 'Name' ) )
725 $name = $ini->variable( $iniGroup, 'Name' );
726 $conversionRules = false;
727 if ( $ini->hasVariable( $iniGroup, 'ConversionRules' ) )
728 {
729 $conversionRules = array();
730 $rules = $ini->variable( $iniGroup, 'ConversionRules' );
731 foreach ( $rules as $ruleString )
732 {
733 $ruleItems = explode( ';', $ruleString );
734 if ( count( $ruleItems ) >= 2 )
735 {
736 $conversionRules[] = array( 'from' => $ruleItems[0],
737 'to' => $ruleItems[1] );
738 }
739 }
740 }
741 $isEnabled = $ini->variable( $iniGroup, 'IsEnabled' ) == 'true';
742 $outputRewriteType = self::REPLACE_SUFFIX;
743 $handler = new eZImageGDHandler( $name, $isEnabled,
744 $outputRewriteType,
745 $conversionRules );
746 return $handler;
747 }
748 return $handler;
749 }
750
752 public $Path;
753 public $Executable;
754 public $PreParameters;
755 public $PostParameters;
756
757 public $InputMap;
758 public $OutputMap;
759 public $OutputQualityMap;
760 public $FilterFunctionMap;
761 public $LuminanceColorScales;
762 public $ThresholdList;
763 public $HandlerName;
764 public $SupportedInputMIMETypes;
765 public $SupportedOutputMIMETypes;
766 public $ConversionRules;
767 public $OutputRewriteType;
768 public $Filters;
769 public $FilterMap;
770 public $SupportImageFilters;
771 public $MIMETagMap;
772 public $IsEnabled;
773 }
774
775 ?>
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZImageGDHandler
The class eZImageGDHandler does.
Definition: ezimagegdhandler.php:24
eZImageGDHandler\calculateFixedHeightAspectGeometry
calculateFixedHeightAspectGeometry( $sourceWidth, $sourceHeight, $destinationHeight, $allowUpScale)
Definition: ezimagegdhandler.php:615
eZImageGDHandler\setImageLuminanceNamed
setImageLuminanceNamed( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:284
eZImageGDHandler\$SupportImageFilters
$SupportImageFilters
Definition: ezimagegdhandler.php:770
eZImageGDHandler\setImageColorspaceGray
setImageColorspaceGray( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:262
eZImageGDHandler\scaleImageHeightDownOnly
scaleImageHeightDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:505
eZImageGDHandler\setImageBorderColor
static setImageBorderColor(&$imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:219
eZImageGDHandler\imageCreate
static imageCreate( $width, $height, $isTrueColor=true)
Definition: ezimagegdhandler.php:684
eZImageGDHandler\$OutputRewriteType
$OutputRewriteType
Definition: ezimagegdhandler.php:767
eZImageGDHandler\$PreParameters
$PreParameters
Definition: ezimagegdhandler.php:754
eZImageGDHandler\$FilterMap
$FilterMap
Definition: ezimagegdhandler.php:769
eZImageGDHandler\scaleImageExact
scaleImageExact( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:517
eZImageGDHandler\$Path
$Path
Definition: ezimagegdhandler.php:752
eZImageGDHandler\isImageTrueColor
static isImageTrueColor(&$imageObject, $mimeData)
Definition: ezimagegdhandler.php:675
eZImageGDHandler\$SupportedOutputMIMETypes
$SupportedOutputMIMETypes
Definition: ezimagegdhandler.php:765
eZImageGDHandler\convert
convert( $manager, $sourceMimeData, &$destinationMimeData, $filters=false)
Definition: ezimagegdhandler.php:120
eZImageGDHandler\scaleImageDownOnly
scaleImageDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:447
eZImageGDHandler\$HandlerName
$HandlerName
Definition: ezimagegdhandler.php:763
eZImageGDHandler\setImageLuminanceColorScale
setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData, $colorScale)
Definition: ezimagegdhandler.php:303
eZImageGDHandler\$ThresholdList
$ThresholdList
Definition: ezimagegdhandler.php:762
eZImageGDHandler\$OutputQualityMap
$OutputQualityMap
Definition: ezimagegdhandler.php:759
eZImageGDHandler\$Filters
$Filters
Definition: ezimagegdhandler.php:768
eZImageGDHandler\setImageColorThresholdName
setImageColorThresholdName( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:343
eZImageGDHandler\$PostParameters
$PostParameters
Definition: ezimagegdhandler.php:755
eZImageGDHandler\$OutputMap
$OutputMap
Definition: ezimagegdhandler.php:758
eZImageGDHandler\cropImage
cropImage( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:409
eZImageGDHandler\calculateScaledAspectGeometry
calculateScaledAspectGeometry( $sourceWidth, $sourceHeight, $destinationWidth, $destinationHeight, $allowUpScale)
Definition: ezimagegdhandler.php:542
eZImageGDHandler\createFromINI
static createFromINI( $iniGroup, $iniFilename=false)
Definition: ezimagegdhandler.php:708
eZImageGDHandler\$ConversionRules
$ConversionRules
Definition: ezimagegdhandler.php:766
eZImageGDHandler\setImageColorThreshold
static setImageColorThreshold( $imageObject, $filterData, $sourceMimeData, $destinationMimeData, $thresholdList)
Definition: ezimagegdhandler.php:365
eZImageGDHandler\scaleImageWidthDownOnly
scaleImageWidthDownOnly( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:490
eZImageGDHandler\scaleImageCopy
static scaleImageCopy( $imageObject, $geometry, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:637
eZImageGDHandler\$MIMETagMap
$MIMETagMap
Definition: ezimagegdhandler.php:771
eZImageGDHandler\$LuminanceColorScales
$LuminanceColorScales
Definition: ezimagegdhandler.php:761
eZImageGDHandler\$FilterFunctionMap
$FilterFunctionMap
Definition: ezimagegdhandler.php:760
eZImageGDHandler\scaleImagePercent
scaleImagePercent( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:527
eZImageGDHandler\calculateScaledPercentAspectGeometry
calculateScaledPercentAspectGeometry( $sourceWidth, $sourceHeight, $destinationWidthPercent, $destinationHeightPercent, $allowUpScale)
Definition: ezimagegdhandler.php:573
eZImageGDHandler\scaleImageHeight
scaleImageHeight( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:475
eZImageGDHandler\createImageBorder
createImageBorder( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:237
eZImageGDHandler\createGeometry
static createGeometry( $width, $height, $x=0, $y=0)
Definition: ezimagegdhandler.php:695
eZImageGDHandler\setImageLuminance
setImageLuminance( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:273
eZImageGDHandler\$InputMap
$InputMap
Definition: ezimagegdhandler.php:757
eZImageGDHandler\setImageBorderWidth
setImageBorderWidth( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:225
eZImageGDHandler\setImageBorder
setImageBorder( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:231
eZImageGDHandler\$SupportedInputMIMETypes
$SupportedInputMIMETypes
Definition: ezimagegdhandler.php:764
eZImageGDHandler\__construct
__construct( $handlerName, $isGloballyEnabled, $outputRewriteType=self::REPLACE_SUFFIX, $conversionRules=false)
Definition: ezimagegdhandler.php:25
eZImageGDHandler\$Executable
$Executable
Definition: ezimagegdhandler.php:753
eZImageGDHandler\imageCopy
static imageCopy( $imageObject, $destinationGeometry, $sourceGeometry, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:658
eZImageGDHandler\$IsEnabled
$IsEnabled
Definition: ezimagegdhandler.php:772
eZImageGDHandler\scaleImageWidth
scaleImageWidth( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:461
eZImageGDHandler\scaleImage
scaleImage( $imageObject, $filterData, &$filterVariables, $sourceMimeData, $destinationMimeData)
Definition: ezimagegdhandler.php:432
eZImageGDHandler\calculateFixedWidthAspectGeometry
calculateFixedWidthAspectGeometry( $sourceWidth, $sourceHeight, $destinationWidth, $allowUpScale)
Definition: ezimagegdhandler.php:590
eZImageHandler
The class eZImageHandler does.
Definition: ezimagehandler.php:19
eZImageHandler\changeFilePermissions
static changeFilePermissions( $filepath)
Definition: ezimagehandler.php:257
eZImageHandler\REPLACE_SUFFIX
const REPLACE_SUFFIX
Definition: ezimagehandler.php:34
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.