PHP code example of kodie / img-items

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

    

kodie / img-items example snippets



tents = file_get_contents('assets/feed-example.png');
$img = imagecreatefromstring($contents);
$items = img_items($img);

foreach($items as $item) {
  for ($y = $item['top']; $y < $item['bottom'] + 1; $y++) {
    for ($x = $item['left']; $x < $item['right'] + 1; $x++) {
      imagesetpixel($img, $x, $y, imagecolorallocate($img, 255, 0, 0));
    }
  }
}

imagepng($img, 'assets/feed-example-filled.png', 0);
imagedestroy($img);


ms = img_items('my-image.jpg', array(
  'background'           => 0,
  'background_threshold' => 5,
  'gap_threshold'        => 5,
  'size_threshold'       => 5
));