PHP code example of pixelcrab / png-chunks
1. Go to this page and download the library: Download pixelcrab/png-chunks 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/ */
pixelcrab / png-chunks example snippets
// Use namespace
use PHPPNG\PNGChunks\PNGChunks;
// Initialize class. Param is a valid PNG file.
$png = new PngChunk(__DIR__ . '/image.png');
// Fetch all tEXt chunks
$chunks = $png->getChunks('tEXt');
// Remove all tEXt chunks
$png->removeChunks('tEXt');
// Add new tEXt chunk
$png->addChunk('tEXt', 'custom', 'my value');
// Some methods are chainable
$png
->removeChunks('tEXt')
->addChunk('tEXt', 'custom', 'my value');