### Install TRMNL Pipeline PHP using Composer Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Installs the TRMNL Pipeline PHP library using the Composer package manager. This is the standard way to add the library to your PHP project. ```bash composer require bnussbau/trmnl-pipeline-php ``` -------------------------------- ### Run Project Tests in Bash Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Executes the project's test suite and generates code coverage reports using Composer. ```bash composer test composer test-coverage ``` -------------------------------- ### Manually configure image processing pipeline Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Illustrates manual configuration of the image processing pipeline, allowing specific settings for format, dimensions, rotation, colors, and bit depth. This provides granular control over the output image. ```php use Bnussbau\TrmnlPipeline\Model; use Bnussbau\TrmnlPipeline\TrmnlPipeline; use Bnussbau\TrmnlPipeline\Stages\ImageStage; use Bnussbau\TrmnlPipeline\Stages\BrowserStage; $html = file_get_contents('./tests/assets/framework2_og.html'); $image = new TrmnlPipeline() ->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"; ``` -------------------------------- ### Basic Pipeline usage for image processing Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Shows the fundamental usage of the Pipeline class to orchestrate image processing stages. It demonstrates setting a model, adding stages like BrowserStage and ImageStage, and processing a payload. ```php $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 ``` -------------------------------- ### Format and Analyze Code Quality in Bash Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Applies code formatting, static analysis, and code refactoring using Composer scripts. ```bash composer format composer analyse composer rector ``` -------------------------------- ### Convert HTML to PNG with BrowserStage in PHP Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Converts HTML content into PNG images using the Spatie Browsershot library. Allows setting dimensions, styles, and other browser rendering options. ```php $browserStage = new BrowserStage(); $browserStage ->html('Content') ->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); ``` -------------------------------- ### Process image using ImageStage with model configuration Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Shows how to process an existing image using the ImageStage, configuring it based on a specific TRMNL model (e.g., OG_BMP). This is useful for applying model-specific optimizations to an image directly. ```php use Bnussbau\TrmnlPipeline\Stages\ImageStage; use Bnussbau\TrmnlPipeline\Model; $imageStage = new ImageStage(); $imageStage->configureFromModel(Model::OG_BMP); $result = $imageStage('./tests/assets/browsershot_og_1bit.png'); echo "Processed image: $result"; ``` -------------------------------- ### Use custom Browsershot implementation with AWS Lambda Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Demonstrates integrating a custom Browsershot implementation, such as BrowsershotLambda for AWS Lambda, into the TRMNL Pipeline. This allows for serverless HTML rendering. ```php use Bnussbau\TrmnlPipeline\Model; use Bnussbau\TrmnlPipeline\TrmnlPipeline; use Bnussbau\TrmnlPipeline\Stages\BrowserStage; use Bnussbau\TrmnlPipeline\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 TrmnlPipeline() ->model(Model::OG) ->pipe(new BrowserStage($browsershotLambda) ->html($html)) ->pipe(new ImageStage()) ->process(); echo "Generated image: $image"; ``` -------------------------------- ### Access Device Model Configurations in PHP Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Retrieves data and properties associated with specific device models. This includes model labels, dimensions, color counts, and bit depth. ```php $model = Model::OG_PNG; $data = $model->getData(); echo $model->getLabel(); // "TRMNL OG (1-bit)" echo $model->getWidth(); // 800 echo $model->getHeight(); // 480 echo $model->getColors(); // 2 echo $model->getBitDepth(); // 1 ``` -------------------------------- ### Render HTML to TRMNL OG model image Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Demonstrates rendering HTML content into an image compatible with the TRMNL OG model. It uses the TrmnlPipeline with BrowserStage for HTML to image conversion and ImageStage for processing. ```php use Bnussbau\TrmnlPipeline\Model; use Bnussbau\TrmnlPipeline\TrmnlPipeline; use Bnussbau\TrmnlPipeline\Stages\ImageStage; use Bnussbau\TrmnlPipeline\Stages\BrowserStage; $html = file_get_contents('./tests/assets/framework2_og.html'); $image = new TrmnlPipeline() ->model(Model::OG) ->pipe(new BrowserStage() ->html($html)) ->pipe(new ImageStage()) ->process(); echo "Generated image: $image"; ``` -------------------------------- ### Process Images for E-Ink Display with ImageStage in PHP Source: https://github.com/bnussbau/trmnl-pipeline-php/blob/main/README.md Processes input images to make them compatible with e-ink displays. Configures output format, dimensions, offsets, rotation, color depth, and output path. ```php $imageStage = new ImageStage(); $imageStage ->format('png') ->width(800) ->height(480) ->offsetX(0) ->offsetY(0) ->rotation(0) ->colors(2) ->bitDepth(1) ->outputPath('/path/to/output.png'); $result = $imageStage('/path/to/input.png'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.