PHP code example of pateon / steganography

1. Go to this page and download the library: Download pateon/steganography 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/ */

    

pateon / steganography example snippets


use Steganography\Processor;

$processor = new Processor();

// Encode a message into an image
$image = $processor->encode('source.jpg', 'This is my secret message! 秘密訊息');
$image->save('output.png'); // MUST save as PNG (lossless)

// Decode the message from the image
$message = $processor->decode('output.png');
echo $message; // "This is my secret message! 秘密訊息"

$processor = new Processor();

// Force GD
$processor->setPreferredAdapter('gd');

// Force Imagick
$processor->setPreferredAdapter('imagick');

$processor = new Processor();
$maxBytes = $processor->calculateMaxMessageSize('source.jpg');
echo "Max message size: ~{$maxBytes} bytes";

use Steganography\Processor;
use Steganography\Compressor\ZlibCompressor;

$processor = new Processor(
    compressor: new ZlibCompressor(level: 9) // Maximum compression
);