/** * Saves $im into the file (many format available). * * @param int $image_style * @param int $quality */ public function finish($image_style = self::IMG_FORMAT_PNG, $quality = 100) { $drawer = null; $im = $this->im; if ($this->rotateDegree > 0.0) { if (function_exists('imagerotate')) { $im = imagerotate($this->im, $this->rotateDegree, $this->color->allocate($this->im)); } else { throw new BCGDrawException('The method imagerotate doesn\'t exist on your server. Do not use any rotation.'); } } if ($image_style === self::IMG_FORMAT_PNG) { $drawer = new BCGDrawPNG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); } elseif ($image_style === self::IMG_FORMAT_JPEG) { $drawer = new BCGDrawJPG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); $drawer->setQuality($quality); } elseif ($image_style === self::IMG_FORMAT_GIF) { // Some PHP versions have a bug if passing 2nd argument as null. if ($this->filename === null || $this->filename === '') { imagegif($im); } else { imagegif($im, $this->filename); } } elseif ($image_style === self::IMG_FORMAT_WBMP) { imagewbmp($im, $this->filename); } if ($drawer !== null) { $drawer->draw(); } }
/** * Save $im into the file (many format available) * * @param int $image_style * @param int $quality */ public function finish($image_style = self::IMG_FORMAT_PNG, $quality = 100) { $drawer = null; $im = $this->im; if ($this->rotateDegree > 0.0) { $im = imagerotate($this->im, $this->rotateDegree, $this->color->allocate($this->im)); } if ($image_style === self::IMG_FORMAT_PNG) { $drawer = new BCGDrawPNG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); } elseif ($image_style === self::IMG_FORMAT_JPEG) { $drawer = new BCGDrawJPG($im); $drawer->setFilename($this->filename); $drawer->setDPI($this->dpi); $drawer->setQuality($quality); } elseif ($image_style === self::IMG_FORMAT_GIF) { imagegif($im, $this->filename); } elseif ($image_style === self::IMG_FORMAT_WBMP) { imagewbmp($im, $this->filename); } if ($drawer !== null) { $drawer->draw(); } }