shop-old/libs/phImaginator/phImaginator.Merge.class.php
2026-04-20 01:03:43 +02:00

52 lines
996 B
PHP

<?php
abstract class phImaginator_Merge extends phImaginator_Universal implements phImaginator_Module {
protected static $runCollected = true;
public static function fitted($params) {
require_once 'phImaginator.Box.class.php';
self::universalMerger('fitted', $params);
}
private static function universalMerger($type, $params) {
$width = $params[0];
$height = $params[1];
$lucency = ($params[2]) ? $params[2] : 50;
if (is_array(parent::$imageSourceCollection)) {
$mergedImage = imagecreatetruecolor($width, $height);
$iteratorCnt = 0;
foreach (parent::$imageSourceCollection as $image_data) {
if ($type == 'fitted') {
phImaginator_Box::fit($image_data, array($width, $height));
}
$useLucency = (++$iteratorCnt > 1) ? $lucency : 100;
imagecopymerge($mergedImage, $image_data['resource'], 0, 0, 0, 0, $image_data['width'], $image_data['height'], $useLucency);
}
parent::replaceSourceCollection($mergedImage);
}
}
}
?>