Changes output format to PNG.

@access public
@return \GImage\Image
347724
public function toPNG()
    {
        $this->extension = 'png';
        $this->type = IMAGETYPE_PNG;
        $this->mimetype = Utils::getMimetypeByImageType(IMAGETYPE_PNG);
        return $this;
    }
546998
protected function buildImageCrop () {
    $image = Image::make($this->upload_path . $this->file_name)->orientate();

    if ($this->preset->width == 0) {
      $image->heighten($this->preset->height);
    }
    else if ($this->preset->height == 0) {
      $image->widen($this->preset->width);
    }
    else {
      $image->fit($this->preset->width, $this->preset->height);
    }

    return $image;
  }
982566
public function toString()
	{
		if ( $this->test() )
		{
			if ( class_exists('\\Imagick') )
				$m = $this->img;
			else
			{
				ob_start();
				\call_user_func('image'.$this->ext2,$this->img);
				$m = ob_get_contents();
				ob_end_clean();
			}
			return 'data:image/'.$this->ext.';base64,'.base64_encode($m);
		}
	}
147724
public function img()
    {
        // Check for an existing Image relation
        if (($image = $this->parentImg($this->inputName()))
            && $image->exists) {

            // If the Image represents a default image, but doesn't match the current
            // item from the config, trash the current one and build the new default
            // image.
            if ($replacement = $this->getReplacementImage($image)) {
                return $replacement;
            }

            // Return the found image
            return $image;
        }

        // Else return a default image
        return $this->defaultImage();
    }
177001
public function postImage()
	{
		$file = Input::file('file');
		$imageDir = Config::get('core::wardrobe.image_dir');
		$destinationPath = public_path(). "/{$imageDir}/";
		$filename = $file->getClientOriginalName();
		$resizeEnabled = Config::get('core::wardrobe.image_resize.enabled');
		
		if ($resizeEnabled)
		{
			$resizeWidth = Config::get('core::wardrobe.image_resize.width');
			$resizeHeight = Config::get('core::wardrobe.image_resize.height');
			$image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true);
			$image->save($destinationPath.$filename);
		}
		else
		{
			$file->move($destinationPath, $filename);
		}

		if (File::exists($destinationPath.$filename))
		{
			// @note - Using the absolute url so it loads images when ran in sub folder
			// this will make exporting less portable and may need to re-address at a later point.
			return Response::json(array('filename' => url("/{$imageDir}/".$filename)));
		}
		return Response::json(array('error' => 'Upload failed. Please ensure your public/img directory is writable.'));
	}
691132
private function openImage()
	{
		try
		{
			$image_atts = getimagesize($this->source);
			if (empty($image_atts))
			{
				return false;
			}

			switch ($image_atts['mime'])
			{
				case 'image/jpeg':
					$this->image_type = IMAGETYPE_JPEG;
					$this->resource   = imagecreatefromjpeg($this->source);
				break;
				case 'image/gif':
					$this->image_type = IMAGETYPE_GIF;
					$this->resource   = imagecreatefromgif($this->source);
				break;
				case 'image/png':
				case 'image/x-png':
					$this->image_type = IMAGETYPE_PNG;
					$this->resource   = imagecreatefrompng($this->source);
				break;
				default:
					return false;
				break;
			}

			if ($this->image_type == IMAGETYPE_PNG)
			{
				imagesavealpha($this->resource, true);
				imagealphablending($this->resource, false);
			}

			if (isset($this->config['auto_rotate']) && $this->config['auto_rotate'] == true)
			{
				$this->autoRotate();
			}

			if (!empty($this->resource))
			{
				return true;
			}
			return false;
		}
		catch (Exception $error)
		{
			$this->setError($error->getMessage());
			return false;
		}
	}
1362835
public function toGIF()
    {
        $this->extension = 'gif';
        $this->type = IMAGETYPE_GIF;
        $this->mimetype = Utils::getMimetypeByImageType(IMAGETYPE_GIF);
        return $this;
    }
1171002
public function getImage(): string
    {
        if (is_resource($this->image)) {
            $this->image = (string) stream_get_contents($this->image);
        }
        return $this->image;
    }
1205855
private function getResource()
    {
        if ($this->mime == 'image/gif') {
            return imagecreatefromgif($this->source);
        }
        elseif ($this->mime == 'image/jpg' || $this->mime == 'image/jpeg') {
            return imagecreatefromjpeg($this->source);
        }
        elseif ($this->mime == 'image/png') {
            return imagecreatefrompng($this->source);
        }
        else
            return null;

    }
363763
public function getPixelFormat()
    {
        if ($this->pixelFormat === null) {
            $match = [];
            preg_match(self::$REGEX_PIXEL_FORMAT, $this->output, $match);
            $this->pixelFormat = array_key_exists(1, $match) ? trim($match[1]) : '';
        }

        return $this->pixelFormat;
    }
375790
public function getImageType()
    {
        $this->imageType = ($this->imageType === 'jpg') ? 'jpeg' : $this->imageType;
        $this->imageType = ( in_array($this->imageType, $this->imageTypes) ) ? $this->imageType : 'png';

        return $this->imageType;
    }
166612
protected function image()
    {
        $locator = Grav::instance()['locator'];

        $file = $this->get('filepath');

        // Use existing cache folder or if it doesn't exist, create it.
        $cacheDir = $locator->findResource('cache://images', true) ?: $locator->findResource('cache://images', true, true);

        // Make sure we free previous image.
        unset($this->image);

        $this->image = ImageFile::open($file)
            ->setCacheDir($cacheDir)
            ->setActualCacheDir($cacheDir)
            ->setPrettyName($this->getImagePrettyName());

        return $this;
    }
529571
protected function leadPNG()
	{
		$exif  = exif_imagetype($this->file) === IMAGETYPE_PNG;

		if ($exif)
		{
			return $this->closeCase("png", "image/png");
		}

		return null;
	}
852508
private function _output($options = array())
    {
        if (!isset($options["type"])) $options["type"] = "png";
        if (!isset($options["page"])) $options["page"] = 1;
        $type = strtolower($options["type"]);

        if (isset($this->_imgs[$options["page"] - 1])) {
            $img = $this->_imgs[$options["page"] - 1];
        } else {
            $img = $this->_imgs[0];
        }

        // Perform any antialiasing
        if ($this->_aa_factor != 1) {
            $dst_w = $this->_actual_width / $this->_aa_factor;
            $dst_h = $this->_actual_height / $this->_aa_factor;
            $dst = imagecreatetruecolor($dst_w, $dst_h);
            imagecopyresampled($dst, $img, 0, 0, 0, 0,
                $dst_w, $dst_h,
                $this->_actual_width, $this->_actual_height);
        } else {
            $dst = $img;
        }

        switch ($type) {
            case "jpg":
            case "jpeg":
                if (!isset($options["quality"])) {
                    $options["quality"] = 75;
                }

                imagejpeg($dst, null, $options["quality"]);
                break;
            case "png":
            default:
                imagepng($dst);
                break;
        }

        if ($this->_aa_factor != 1) {
            imagedestroy($dst);
        }
    }
642574
public function display()
    {
        $imageType = $this->getImageType();

        header('Content-type: image/' . $imageType);

        $imageFunc = 'image' . $imageType;
        $imageFunc($this->image);

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

        return $this;
    }
1318418
public function renderImage()
    {
        $rules = array();
        foreach ($this->rules as $rule) {
            $rules[] = '[' . implode(", ", $rule) . ']';
        }
        $this->htmlOptions['data-interchange'] = implode(", ", $rules);
        return \CHtml::tag('img', $this->htmlOptions);
    }
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;
    }