Converts the image's color to grayscale.

```php
$img = new bbn\file\image("/home/data/test/image.jpg");
$img->grayscale()->save();
```

@return image
182933
public function grayscale()
	{
		if ( $this->test() )
		{
			if ( class_exists('\\Imagick') )
			{
				if ( !$this->img->modulateImage(100,0,100) ){
					$this->error = \defined('BBN_THERE_HAS_BEEN_A_PROBLEM') ?
						BBN_THERE_HAS_BEEN_A_PROBLEM : 'There has been a problem';
				}
			}
			else if ( function_exists('imagefilter') )
			{
				if ( !imagefilter($this->img,IMG_FILTER_GRAYSCALE) ){
					$this->error = \defined('BBN_THERE_HAS_BEEN_A_PROBLEM') ?
						BBN_THERE_HAS_BEEN_A_PROBLEM : 'There has been a problem';
				}
			}
		}
		return $this;
	}
361080
protected function do_greyscale(\stdClass $src) {

		$dst = new \stdClass();
		$dst->resource	= imagecreatetruecolor($src->width, $src->height);
		$dst->width		= $src->width;
		$dst->height	= $src->height;

		imagecopy($dst->resource, $src->resource, 0, 0, 0, 0, $src->width, $src->height);
		imagefilter($dst->resource, IMG_FILTER_GRAYSCALE);
		return $dst;
	}
788112
protected function processPng()
    {
        $format = 'png';
        $compression = \Imagick::COMPRESSION_ZIP;

        $imagick = $this->image->getCore();
        $imagick->setFormat($format);
        $imagick->setImageFormat($format);
        $imagick->setCompression($compression);
        $imagick->setImageCompression($compression);

        return $imagick->getImagesBlob();
    }
1225941
function dump() {
		$args=func_get_args();
		$format=$args?array_shift($args):'png';
		ob_start();
		call_user_func_array(
			'image'.$format,
			array_merge([$this->data,NULL],$args)
		);
		return ob_get_clean();
	}
559337
function flatten()
    {
        $i = 0;
        $hasFirst = false;
        $firstImageLayer = null;
        $firstImageLayerData = null;
        while ( $i < count( $this->ImageLayers ) and
                !$hasFirst )
        {
            $layerID = $this->ImageLayers[$i];
            $layerData =& $this->ImageLayerIndex[$layerID];
            $layer = $layerData['image'];
            if ( $layer instanceof eZImageLayer )
            {
                $firstImageLayerData = $layerData;
                $firstImageLayer = $layer;
                $hasFirst = true;
            }
            else
                eZDebug::writeWarning( 'Wrong image type ' . gettype( $layer ), __METHOD__ );
            ++$i;
        }
        if ( $hasFirst )
        {
            $lastImageLayerData = null;
            $firstImageLayer->imageObject();
            if ( !$this->width() )
            {
                $this->setWidth( $firstImageLayer->width() );
            }
            if ( !$this->height() )
            {
                $this->setHeight( $firstImageLayer->height() );
            }
            $firstImageLayer->mergeLayer( $this,
                                          $firstImageLayerData,
                                          $lastImageLayerData );
            $lastImageLayerData = null;
            while ( $i < count( $this->ImageLayers ) )
            {
                $layerID = $this->ImageLayers[$i];
                $layerData =& $this->ImageLayerIndex[$layerID];
                $layer = $layerData['image'];
                unset( $imageObject );
                if ( $layer instanceof eZImageLayer )
                {
                    $layer->mergeLayer( $this,
                                        $layerData,
                                        $lastImageLayerData );
                    $lastImageLayerData = $layerData;
                }
                else
                {
                    eZDebug::writeWarning( 'Wrong image type ' . gettype( $layer ), __METHOD__ );
                }
                ++$i;
            }
            return true;
        }
        return false;
    }
248328
public function render(): Image {
        $ftbbox = imageftbbox($this->fontSize, 0, $this->fontFile, $this->text, $this->extraInfo);

        $width = max($ftbbox[2] - $ftbbox[6], 1);
        $height = max($ftbbox[3] - $ftbbox[7], 1);

        // Getting an offset for the first symbol of text
        $ftbbox = imageftbbox($this->fontSize, 0, $this->fontFile, $this->text[0] ?? '', $this->extraInfo);
        $offset = $ftbbox[3] - $ftbbox[7];

        $image = Utility::transparentImage($width, $height);
        imagefttext(
            $image->getResource(),
            $this->fontSize,
            0,
            0,
            $offset,
            $this->color->allocate($image->getResource()),
            $this->fontFile,
            $this->text,
            $this->extraInfo
        );

        return $image;
    }
238020
function sepia() {
        imagefilter($this->image, IMG_FILTER_GRAYSCALE);
        imagefilter($this->image, IMG_FILTER_COLORIZE, 100, 50, 0);
        return $this;
    }
1111905
public function greyScaleEnhanced()
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Make image greyscale
		# Param in:   n/a
		# Param out:
		# Reference:
		# Notes:
		#
	{
		if ($this->imageResized)
		{
			imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
			imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
			imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, 2);
			$this->sharpen($this->width);
		}
	}
293543
public function apply( $image ) {

        imagefilter($image->getCore(), IMG_FILTER_COLORIZE, $this->red, $this->green, $this->blue);
        return $image;
    }
225042
public function getImage()
    {
        // No fields, no image.
        if (empty($this->contenttype['fields'])) {
            return '';
        }

        // Grab the first field of type 'image', and return that.
        foreach ($this->contenttype['fields'] as $key => $field) {
            if ($field['type'] === 'image' && isset($this->values[$key])) {
                // After v1.5.1 we store image data as an array
                if (is_array($this->values[$key])) {
                    return isset($this->values[$key]['file']) ? $this->values[$key]['file'] : '';
                }

                return $this->values[$key];
            }
        }

        // otherwise, no image.
        return '';
    }
318868
public function genImage()
    {
        $this->image = imagecreatetruecolor($this->getPxRatio() * 5, $this->getPxRatio() * 5);

        $bg = $this->getBgColor();
        if (!empty($bg)) {
            $background = imagecolorallocate($this->image, $bg[0], $bg[1], $bg[2]);
            imagefill($this->image, 0, 0, $background);
        } else {
            $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
            imagefill($this->image, 0, 0, $transparent);
            imagesavealpha($this->image, true);
        }
        $color = $this->getColor();
        $color = imagecolorallocate($this->image, $color[0], $color[1], $color[2]);
        $font = __DIR__.DIRECTORY_SEPARATOR.'\fonts\arial.ttf';
        imagettftext($this->image, $this->getPxRatio() * 3, 0, round(($this->getPxRatio() * 5) / 5.5), round(($this->getPxRatio() * 5) / 1.3), $color, $font, $this->getCharacter());

        return $this->image;
    }
1197782
public function create()
    {
        /**
         * @var ImageInterface $image
         */
        $classNamespace = $this->getEntityNamespace();
        $image = new $classNamespace();
        $image
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $image;
    }
444662
private function getBackgroundColor($img = null)
    {
        $img = isset($img) ? $img : $this->image;

        if ($this->bgColorDefault) {

            $red   = $this->bgColorDefault['red'];
            $green = $this->bgColorDefault['green'];
            $blue  = $this->bgColorDefault['blue'];
            $alpha = $this->bgColorDefault['alpha'];

            if ($alpha) {
                $color = imagecolorallocatealpha($img, $red, $green, $blue, $alpha);
            } else {
                $color = imagecolorallocate($img, $red, $green, $blue);
            }

            return $color;

        } else {
            return 0;
        }
    }
1184687
protected function processPng()
    {
        ob_start();
        $resource = $this->image->getCore();
        imagealphablending($resource, false);
        imagesavealpha($resource, true);
        imagepng($resource, null, -1);
        $this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG);
        $buffer = ob_get_contents();
        ob_end_clean();

        return $buffer;
    }
532654
public function getImageBlob()
    {
        if (!$this->processed) {
            return file_get_contents($this->source);
        }

        if ($this->isMultipartImage()) {

            $this->tmpFile = tempnam($this->tmp, 'jitim_');

            $image = $this->resource->deconstructImages();
            $image->writeImages($this->tmpFile, true);

            $image->clear();
            $image->destroy();

            return file_get_contents($this->tmpFile);

        }

        return $this->resource->getImageBlob();
    }
596048
function gray($do = false)
    {
		if (!$do){
            $this->_transforms[] = array('gray', array(true));
            $this->_transforms_str.='gray()';
        }else{
            imagefilter($this->handler(), IMG_FILTER_GRAYSCALE);
        }
		return $this;
	}
1265596
public function image() {
		if (empty($this->_stub['image-src'])) {
			return '';
		}
		$thumb = $this->_stub['image-src'];

		$count = count($this->_match);
		for ($i = 1; $i <= $count; $i++) {
			$thumb = str_ireplace('$' . $i, $this->_match[$i - 1], $thumb);
		}

		return $thumb;
	}