app/Http/Controllers/Admin/ImportThumbnailsController.php
private function scaledImagePixels($path): array
    {
        $size       = 10;
        $sha1       = sha1_file($path);
        $cache_file = WT_DATA_DIR . 'cache/' . $sha1 . '.php';

        if (file_exists($cache_file)) {
            return include $cache_file;
        }

        $manager = new ImageManager();
        $image   = $manager->make($path)->resize($size, $size);

        $pixels = [];
        for ($x = 0; $x < $size; ++$x) {
            $pixels[$x] = [];
            for ($y = 0; $y < $size; ++$y) {
                $pixel          = $image->pickColor($x, $y);
                $pixels[$x][$y] = (int) (($pixel[0] + $pixel[1] + $pixel[2]) / 3);
            }
        }

        file_put_contents($cache_file, '<?php return ' . var_export($pixels, true) . ';');

        return $pixels;
    }
private function scaledImagePixels($path): array
    {
        $size       = 10;
        $sha1       = sha1_file($path);
        $cache_file = WT_DATA_DIR . 'cache/' . $sha1 . '.php';

        if (file_exists($cache_file)) {
            return include $cache_file;
        }

        $manager = new ImageManager();
        $image   = $manager->make($path)->resize($size, $size);

        $pixels = [];
        for ($x = 0; $x < $size; ++$x) {
            $pixels[$x] = [];
            for ($y = 0; $y < $size; ++$y) {
                $pixel          = $image->pickColor($x, $y);
                $pixels[$x][$y] = (int) (($pixel[0] + $pixel[1] + $pixel[2]) / 3);
            }
        }

        file_put_contents($cache_file, '<?php return ' . var_export($pixels, true) . ';');

        return $pixels;
    }
private function scaledImagePixels ( $ path ) : array { $ size = 10 ; $ sha1 = sha1_file ( $ path ) ; $ cache_file = WT_DATA_DIR . 'cache/' . $ sha1 . '.php' ; if ( file_exists ( $ cache_file ) ) { return include $ cache_file ; } $ manager = new ImageManager ( ) ; $ image = $ manager -> make ( $ path ) -> resize ( $ size , $ size ) ; $ pixels = [ ] ; for ( $ x = 0 ; $ x < $ size ; ++ $ x ) { $ pixels [ $ x ] = [ ] ; for ( $ y = 0 ; $ y < $ size ; ++ $ y ) { $ pixel = $ image -> pickColor ( $ x , $ y ) ; $ pixels [ $ x ] [ $ y ] = ( int ) ( ( $ pixel [ 0 ] + $ pixel [ 1 ] + $ pixel [ 2 ] ) / 3 ) ; } } file_put_contents ( $ cache_file , '<?php return ' . var_export ( $ pixels , true ) . ';' ) ; return $ pixels ; }
Scale an image to 10x10 and read the individual pixels.
This is a slow operation, add we will do it many times on
the "import wetbrees 1 thumbnails" page so cache the results.

@param string $path

@return int[][]
Scale an image to 10x10 and read the individual pixels . This is a slow operation add we will do it many times on the import wetbrees 1 thumbnails page so cache the results .