1. Go to this page and download the library: Download bnussbau/trmnl-pipeline-php 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/ */
bnussbau / trmnl-pipeline-php example snippets
use Bnussbau\EpaperPipeline\Model;
use Bnussbau\EpaperPipeline\EpaperPipeline;
use Bnussbau\EpaperPipeline\Stages\ImageStage;
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
$html = file_get_contents('./tests/assets/framework2_og.html');
$image = new EpaperPipeline()
->model(Model::OG)
->pipe(new BrowserStage()
->html($html))
->pipe(new ImageStage())
->process();
echo "Generated image: $image";
use Bnussbau\EpaperPipeline\Stages\ImageStage;
use Bnussbau\EpaperPipeline\Model;
$imageStage = new ImageStage();
$imageStage->configureFromModel(Model::OG_BMP);
$result = $imageStage('./tests/assets/browsershot_og_1bit.png');
echo "Processed image: $result";
use Bnussbau\EpaperPipeline\Model;
use Bnussbau\EpaperPipeline\EpaperPipeline;
use Bnussbau\EpaperPipeline\Stages\ImageStage;
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
$html = file_get_contents('./tests/assets/framework2_og.html');
$image = new EpaperPipeline()
->pipe(new BrowserStage()
->html($html))
->pipe(new ImageStage()
->format('png')
->width(800)
->height(600)
->rotation(90)
->colors(256)
->bitDepth(8))
->process();
echo "Generated image: $image";
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
$image = (new \Bnussbau\EpaperPipeline\EpaperPipeline())
->pipe((new BrowserStage())
->timezone('America/New_York')
->html('<html><body><script>document.write(new Date().toString())</script></body></html>'))
->pipe(new \Bnussbau\EpaperPipeline\Stages\ImageStage())
->process();
use Bnussbau\EpaperPipeline\Model;
use Bnussbau\EpaperPipeline\EpaperPipeline;
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
use Bnussbau\EpaperPipeline\Stages\ImageStage;
use Wnx\SidecarBrowsershot\BrowsershotLambda;
$html = file_get_contents('./tests/assets/framework2_og.html');
// Create your custom Browsershot instance (e.g., BrowsershotLambda)
$browsershotLambda = new BrowsershotLambda();
$image = new EpaperPipeline()
->model(Model::OG)
->pipe(new BrowserStage($browsershotLambda)
->html($html))
->pipe(new ImageStage())
->process();
echo "Generated image: $image";
use Bnussbau\EpaperPipeline\Model;
use Bnussbau\EpaperPipeline\EpaperPipeline;
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
use Bnussbau\EpaperPipeline\Stages\ImageStage;
// Enable fake mode for testing
EpaperPipeline::fake();
$html = '<html><body>Test Content</body></html>';
$result = (new EpaperPipeline())
->model(Model::OG)
->pipe(new BrowserStage()->html($html))
->pipe(new ImageStage())
->process();
echo "Mock image generated: $result";
// Enable fake mode with a seed to produce distinct mock images per seed
EpaperPipeline::fake(seed: 'plugin-1');
$seededResult = (new EpaperPipeline())
->model(Model::OG)
->pipe(new BrowserStage()->html($html))
->pipe(new ImageStage())
->process();
echo "Seeded mock image generated: $seededResult";
// Disable fake mode when done
EpaperPipeline::restore();
$pipeline = new Pipeline();
$pipeline->model(Model::OG_PNG); // Set model for automatic configuration
$pipeline->pipe(new BrowserStage()); // Add browser stage
$pipeline->pipe(new ImageStage()); // Add image stage
$result = $pipeline->process($payload); // Process payload
$browserStage = new BrowserStage();
$browserStage
->html('<html><body>Content</body></html>')
->width(800)
->height(480)
->useDefaultDimensions() // force 800x480 e.g. in combination with Model to upscale image
->setBrowsershotOption('addStyleTag', json_encode(['content' => 'body{ color: red; }']));
$result = $browserStage(null);
$image = (new EpaperPipeline())
->model(Model::OG)
->pipe((new BrowserStage())->url('https://example.com'))
->pipe((new ImageStage())->dither())
->process();
use Bnussbau\EpaperPipeline\Stages\ImageStage;
(new ImageStage())
->dither()
->colors(2)
->bitDepth(1);
use Bnussbau\EpaperPipeline\Model;
use Bnussbau\EpaperPipeline\EpaperPipeline;
use Bnussbau\EpaperPipeline\Stages\BrowserStage;
use Bnussbau\EpaperPipeline\Stages\ImageStage;
$html = file_get_contents('./tests/assets/color_6a_test.html');
// Inky Impression 13.3 model has color-6a palette (6 colors: red, green, blue, yellow, black, white)
$image = new EpaperPipeline()
->model(Model::INKY_IMPRESSION_13_3)
->pipe(new BrowserStage()
->html($html))
->pipe(new ImageStage())
->process();
echo "Generated color image: $image";
use Bnussbau\EpaperPipeline\Stages\ImageStage;
// Define custom color palette (6 colors)
$colorPalette = [
'#FF0000', // Red
'#00FF00', // Green
'#0000FF', // Blue
'#FFFF00', // Yellow
'#000000', // Black
'#FFFFFF', // White
];
$imageStage = new ImageStage();
$imageStage
->format('png')
->colormap($colorPalette)
->dither(true); // Dithering works with color palettes (optional; only use for images)
$result = $imageStage('/path/to/input.png');
echo "Processed color image: $result";