CAsciiArt.php
public function createFromFile($filename)
    {
        $img = imagecreatefromstring(file_get_contents($filename));
        list($width, $height) = getimagesize($filename);

        $ascii = null;
        $incY = $this->scale;
        $incX = $this->scale / 2;
        
        for ($y = 0; $y < $height - 1; $y += $incY) {
            for ($x = 0; $x < $width - 1; $x += $incX) {
                $toX = min($x + $this->scale / 2, $width - 1);
                $toY = min($y + $this->scale, $height - 1);
                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);
                $ascii .= $this->luminance2character($luminance);
            }
            $ascii .= PHP_EOL;
        }

        return $ascii;
    }
public function createFromFile($filename)
    {
        $img = imagecreatefromstring(file_get_contents($filename));
        list($width, $height) = getimagesize($filename);

        $ascii = null;
        $incY = $this->scale;
        $incX = $this->scale / 2;
        
        for ($y = 0; $y < $height - 1; $y += $incY) {
            for ($x = 0; $x < $width - 1; $x += $incX) {
                $toX = min($x + $this->scale / 2, $width - 1);
                $toY = min($y + $this->scale, $height - 1);
                $luminance = $this->luminanceAreaAverage($img, $x, $y, $toX, $toY);
                $ascii .= $this->luminance2character($luminance);
            }
            $ascii .= PHP_EOL;
        }

        return $ascii;
    }
public function createFromFile ( $ filename ) { $ img = imagecreatefromstring ( file_get_contents ( $ filename ) ) ; list ( $ width , $ height ) = getimagesize ( $ filename ) ; $ ascii = null ; $ incY = $ this -> scale ; $ incX = $ this -> scale / 2 ; for ( $ y = 0 ; $ y < $ height - 1 ; $ y += $ incY ) { for ( $ x = 0 ; $ x < $ width - 1 ; $ x += $ incX ) { $ toX = min ( $ x + $ this -> scale / 2 , $ width - 1 ) ; $ toY = min ( $ y + $ this -> scale , $ height - 1 ) ; $ luminance = $ this -> luminanceAreaAverage ( $ img , $ x , $ y , $ toX , $ toY ) ; $ ascii .= $ this -> luminance2character ( $ luminance ) ; } $ ascii .= PHP_EOL ; } return $ ascii ; }
Create an Ascii image from an image file.

@param string $filename of the image to use.

@return string $ascii with the ASCII image.
Create an Ascii image from an image file .