diff --git a/README.md b/README.md index e80616c..e1337c6 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,11 @@ You can set the quality of compression from 0 to 100: $pdf->setCompressionQuality(100); // sets the compression quality to maximum ``` -You can create a thumbnail of the pdf: +You can specify the width of the resulting image: ```php -$pdf->setThumbnailWidth(400) - ->saveImage($pathToWhereImageShouldBeStored); +$pdf + ->width(400) + ->saveImage($pathToWhereImageShouldBeStored); ``` ## Issues regarding Ghostscript diff --git a/src/Pdf.php b/src/Pdf.php index f2247bc..2127d60 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -168,13 +168,13 @@ public function getImageData(string $pathToImage): Imagick if (is_int($this->layerMethod)) { $this->imagick = $this->imagick->mergeImageLayers($this->layerMethod); } - + if ($this->thumbnailWidth !== null) { $this->imagick->thumbnailImage($this->thumbnailWidth, 0); } $this->imagick->setFormat($this->determineOutputFormat($pathToImage)); - + return $this->imagick; } @@ -192,7 +192,7 @@ public function setCompressionQuality(int $compressionQuality) return $this; } - public function setThumbnailWidth(int $thumbnailWidth) + public function width(int $thumbnailWidth) { $this->thumbnailWidth = $thumbnailWidth; diff --git a/tests/PdfTest.php b/tests/PdfTest.php index 0c6bdd3..9c7646d 100644 --- a/tests/PdfTest.php +++ b/tests/PdfTest.php @@ -54,7 +54,7 @@ $imagick = (new Pdf($this->testFile)) ->setOutputFormat('png') ->getImageData('test.png'); - + expect($imagick->getFormat())->toEqual('png'); expect($imagick->getFormat())->not->toEqual('jpg'); }); @@ -65,7 +65,7 @@ ->setResolution(72) ->getImageData('test.jpg') ->getImageResolution(); - + expect($image['x'])->toEqual(72); expect($image['y'])->toEqual(72); }); @@ -80,9 +80,9 @@ it('will create a thumbnail at specified width', function() { $imagick = (new Pdf($this->multipageTestFile)) - ->setThumbnailWidth(400) + ->width(400) ->getImageData('test.jpg') ->getImageGeometry(); expect($imagick['width'])->toBe(400); -}); \ No newline at end of file +});