1. Go to this page and download the library: Download wordpressvn/poster-editor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wordpressvn / poster-editor example snippets
// Using composer
/ new PosterEditor\PosterEditor();
$image->make('images/bridge.jpg')->fit(600, 600);
$image->show();
} catch(Exception $e) {
echo $e->getMessage();
}
$image = new PosterEditor\PosterEditor();
$image->make('images/bridge.jpg')->fit(1200, 630, 'bottom')->blackout(50);
$logo = new PosterEditor\PosterEditor();
$logo->make('images/logo.png')->downsize(150, null);
$image->insert($logo, array('x' => 50, 'y' => 50))->show();
$image = new PosterEditor\PosterEditor();
$image->make('images/bridge.jpg')->fit(1200, 630);
$image->grayscale()->brightness(-40);
$image->text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat Lorem ipsum dolor sit amet', // phpcs:ignore
array(
'x' => 100,
'y' => 100,
'width' => 1000,
'height' => 400,
'horizontal' => 'center',
'vertical' => 'center',
'fontpath' => 'fonts/opensans.ttf',
'fontsize' => 24,
'lineheight' => 1.75,
'color' => '#ffffff',
'opacity' => 0,
'debug' => true,
)
);
$image->show('jpg', 70);
$image = new PosterEditor\PosterEditor();
$image->make('images/bridge.jpg')->fit(900, 600);
$image->blackout(70);
$image->text(
'Lorem ipsum dolor d d 4 g sit amet, consectetur adipiscing et, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex eas commodo consequat sdfsdfl', // phpcs:ignore
array(
'x' => 100,
'y' => 100,
'width' => 600,
'height' => 400,
'horizontal' => 'justify',
'vertical' => 'justify',
'fontpath' => 'fonts/opensans.ttf',
'fontsize' => 20,
'lineheight' => 1.5,
'color' => '#ffffff',
'opacity' => 0,
'debug' => true,
)
);
$image->show('png');
$image = new PosterEditor\PosterEditor();
$image->make('images/bridge.jpg')->crop(
900, 600,
array(
'x' => '0',
'y' => '100'
)
);
$image->grayscale()->brightness(-40);
$image->text(
'Large title with unknown height. Can be multi-line',
array(
'x' => 50,
'y' => 100,
'width' => 800,
'fontpath' => '/fonts/merriweather.ttf',
'fontsize' => 48,
'lineheight' => 1.5,
'color' => '#9999ff',
),
$boundary
);
$image->text(
'This text appears right after title using smart boundaries',
array(
'x' => 50,
'y' => $boundary['y'] + $boundary['height'],
'width' => 800,
'fontpath' => '/fonts/opensans.ttf',
'fontsize' => 20,
'lineheight' => 1.5,
'color' => '#ff9999',
),
$boundary
);
$image->show();