$whirl->clearCache(); break; case 'fetch': $whirl = new Whirl($options); $results = $whirl->getResults(); if (!file_exists($whirl->cacheDir . '/fetched-results.json')) { touch($whirl->cacheDir . '/fetched-results.json'); } file_put_contents($whirl->cacheDir . '/fetched-results.json', json_encode($results)); break; case 'save': $whirl = new Whirl($options); $json = file_get_contents($whirl->cacheDir . '/fetched-results.json'); $fetchedResults = json_decode($json); $whirl->saveResults($fetchedResults); break; case 'resize': $whirl = new Whirl($options); $whirl->resizeResults(); break; case 'multiply': $whirl = new Whirl($options); $result = $whirl->multiplyResults(); break; case 'final': $whirl = new Whirl($options); $result = $whirl->finalImage(); echo $result; break; } }
<?php include 'library/debug.php'; include 'library/whirl.class.php'; // demo $options = array(); $options['term'] = 'zitrone'; $options['quantity'] = 10; // $options['blendMode'] = 'multiply'; // $options['blendOpacity'] = '100'; // $options['alphaBlendMode'] = 'normal'; $options['finalImageWidth'] = 500; $options['finalImageHeight'] = null; $options['finalImageSizing'] = 'default'; // $options['backgroundColor'] = 'transparent'; // $options['effectColorizeRgba'] = '0,255,0,1'; // $options['effectList'] = 'colorize'; $options['cacheDir'] = dirname(__FILE__) . '/cache'; $whirl = new Whirl($options); // $results = $whirl->getResults(); // de($results); $whirl->whirl(); $finalImage = $whirl->finalImage(); echo '<img src="cache/blend/' . $finalImage . '">';
<?php include '../library/debug.php'; include '../library/whirl.class.php'; $options['term'] = 'zitrone'; $options['quantity'] = 4; $options['cacheDir'] = dirname(__FILE__) . '/../cache'; $whirl = new Whirl($options); // insert the blend mode to proof here $blendMode = 'softLight'; $baseImage = imagecreatefrompng('blendtests/blend-test1.png'); $topImage = imagecreatefrompng('blendtests/blend-test1-invert.png'); $proofImage = imagecreatefrompng('blendtests/png/blend-' . $blendMode . '.png'); $blendImage = $whirl->blend($baseImage, $topImage, $blendMode); $baseWidth = imagesx($baseImage); $baseHeight = imagesy($baseImage); $topWidth = imagesx($topImage); $topHeight = imagesy($topImage); $proofWidth = imagesx($proofImage); $proofHeight = imagesy($proofImage); $blendWidth = imagesx($blendImage); $blendHeight = imagesy($blendImage); $finalImageWidth = ($proofWidth + $blendWidth) / 2; $finalImageHeight = $proofHeight + $blendHeight; $destX = ($baseWidth - $topWidth) / 2; $destY = ($baseHeight - $topHeight) / 2; $finalImage = imagecreatetruecolor($finalImageWidth, $finalImageHeight); imagecopy($finalImage, $proofImage, 0, 0, 0, 0, $proofWidth, $proofHeight); imagecopy($finalImage, $blendImage, 0, $proofHeight, 0, 0, $blendWidth, $blendHeight); header('Content-Type: image/png'); imagepng($finalImage);