/** * Writes the image to a file. * * @param string $file */ public function toFile($file) { switch ($this->type->getId()) { case IMAGETYPE_BMP: imagewbmp($this->resource, $file); break; case IMAGETYPE_GIF: imagegif($this->resource, $file); break; case IMAGETYPE_JPEG: imageinterlace($this->resource, 1); imagejpeg($this->resource, $file, static::$quality); break; case IMAGETYPE_PNG: $compression = static::convertJpegQualityToPngCompression(static::$quality); imagepng($this->resource, $file, $compression); break; default: throw new \RuntimeException('Unknown image type'); } }
/** * {@inheritdoc} */ public function jsonSerialize() { return ['dims' => [$this->dimensions->getWidth(), $this->dimensions->getHeight()], 'type' => $this->type->getId(), 'bits' => $this->bits, 'channels' => $this->channels, 'mime' => $this->mime, 'exif' => $this->exif->getData()]; }