*/
protected $version = 'html';
+ protected $quality = 85;
+
/**
* @var ProcessPage
*/
protected $job;
- public function __construct($format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html') {
+ public function __construct($format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html', $quality = 85) {
$this->format = $format;
$this->resolution = $resolution;
$this->withGraphics = $withGraphics;
$this->withTexts = $withTexts;
$this->version = $version;
+ $this->setQuality($quality);
}
/**
}
} else if (in_array($this->getFormat(), ['png', 'jpg'])) {
if ($this->getResolution() === 'thumb') {
- PDFTools::makeMiniShot($this->getSplittedPDFPage(), $file, 1, $this->getFormat());
+ PDFTools::makeMiniShot($this->getSplittedPDFPage(), $file, 1, $this->getFormat(), $this->getQuality());
} else {
$rr = $this->getVersion() === 'html' ? $this->getResolutionRatio() : $this->getMobileRatio();
- PDFTools::makeShotPNM($this->getSplittedPDFPage(), $file, 1, '', $this->getResolution() * $rr, 85, 4, $this->isWithTexts(), null, null, $this->getFormat());
+ PDFTools::makeShotPNM($this->getSplittedPDFPage(), $file, 1, '', $this->getResolution() * $rr, $this->getQuality(), 4, $this->isWithTexts(), null, null, $this->getFormat());
}
} else if ($this->getFormat() === 'swf') {
- PDFTools::makeSWF($this->getSplittedPDFPage(), $file, 1, $this->getResolution(), 80);
+ PDFTools::makeSWF($this->getSplittedPDFPage(), $file, 1, $this->getResolution(), $this->getQuality());
}
unlink($lock);
if (!file_exists($file)) {
}
-
public function makeOptimizedSVGFile($out) {
$in = $this->makeSVGFile();
SVGTools::optimizeSVGImages($in, $out, $this->getResolution());
}
return $res;
}
+
+ /**
+ * @return int
+ */
+ public function getQuality(): int {
+ return $this->quality;
+ }
+
+ /**
+ * @param int $quality
+ */
+ public function setQuality(int $quality): void {
+ $this->quality = max(0, min(100, round($quality)));
+ }
}