( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
require 'vendor/autoload.php';
use PHPImageWorkshop\ImageWorkshop;
$width = 1200;
$height = 1200;
$backgroundColor = 'ffffff'; // optionnal, can be null to transparent
$norwayLayer = ImageWorkshop::initVirginLayer($width, $height, $backgroundColor);
$pinguLayer = ImageWorkshop::initFromPath('pingu.jpg');
$norwayLayer->addLayer(1, $pinguLayer, 0, 0, "MM");
//$norwayLayer = ImageWorkshop::initFromPath('pingu.jpg');
// This is the text layer
$textLayer = ImageWorkshop::initTextLayer('© PHP Image Workshop', 'Bangers-Regular.ttf', 11, 'ffffff', 0);
// We add the text layer 12px from the Left and 12px from the Bottom ("LB") of the norway layer:
$norwayLayer->addLayerOnTop($textLayer, 12, 12, "LB");
$watermarkLayer = ImageWorkshop::initFromPath('watermark.png');
// We proceed to the $watermarkLayer rotation
$watermarkLayer->rotate(90);
$norwayLayer->addLayer(1, $watermarkLayer, 70, 12, "LB");
$norwayLayer->addLayer(1, $watermarkLayer, 30, 10, "RT");
$textLayer = ImageWorkshop::initTextLayer('© PHP Image Workshop', 'Bangers-Regular.ttf', 22, 'ffffff', 0);
// Some funky opacity
$textLayer->opacity(60);
// We add the $textLayer on the norway layer, in its middle
$norwayLayer->addLayer(1, $textLayer, 0, 0, 'MM');
$norwayLayer->applyFilter(IMG_FILTER_CONTRAST, -15, null, null, null, true); // constrast
$norwayLayer->applyFilter(IMG_FILTER_BRIGHTNESS, 8, null, null, null, true); // brightness
// Resize to get the thumbnail
//$norwayLayer->resizeInPixel(300, 120, true, 0, 0, 'MM');
// Get a square ("MM" to say in the middle of the layer) of the maximum possible
//$norwayLayer->cropMaximumInPixel(0, 0, "MM");
$image = $norwayLayer->getResult();
// Saving the result
$dirPath = __DIR__."/done";
$filename = "pingu_edited.png";
$createFolders = true;
$backgroundColor = null; // transparent, only for PNG (otherwise it will be white if set null)
$imageQuality = 95; // useless for GIF, usefull for PNG and JPEG (0 to 100%)
$norwayLayer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
header('Content-type: image/png');
imagejpeg($image, null, 95); // We chose to show a JPG with a quality of 95%
exit;
?>