PHP code example of kiatng / php-sharp

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

    

kiatng / php-sharp example snippets


use KiatNg\Sharp;

$png = Sharp::run(
    [
        'input' => ['is_raw' => true, 'data' => $svg, 'ext' => 'svg'],
        'output' => ['is_raw' => true],
    ],
    [
        'toFormat' => ['format' => 'png'], // Required for raw output
        'resize' => ['width' => 300, 'height' => 200]
    ]
); // Returns a raw PNG binary string

Sharp::run(
    [
        'input' => ['is_raw' => false, 'data' => $svgPath],
        'output' => ['is_raw' => false, 'file' => $pngPath],
    ],
    [
        //'toFormat' => ['format' => 'png'], Not