PHP code example of sbolch / gd-image

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

    

sbolch / gd-image example snippets



  // ...
  use sbolch\GDImage\Converter;
  // ...
  class Demo {
    public function demo() {
      $img = 'path/to/image.png';

      $converter = new Converter();
      $converter
        ->image($img)
        ->toJpg()
        ->target('path/to/converted-image.jpg')
        ->save();
    }
  }


  // ...
  use sbolch\GDImage\Sizer;
  // ...
  class Demo {
    public function demo() {
      $img = 'path/to/image.jpg';

      $sizer = new Sizer();
      $sizer
        ->image($img)
        ->thumbnail(400, 300)
        ->save();
    }
  }


  // ...
  use sbolch\GDImage\CachedSizer;
  // ...
  class Demo {
    public function demo() {
      $img = 'path/to/image.jpg';

      $sizer = new CachedSizer();
      $sizer
        ->image($img)
        ->thumbnail(400, 300)
        ->save();
    }
  }