Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Mar 8, 2022
1 parent 6beafb7 commit 9b8d5ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -192,7 +192,7 @@ public function setCompressionQuality(int $compressionQuality)
return $this;
}

public function setThumbnailWidth(int $thumbnailWidth)
public function width(int $thumbnailWidth)
{
$this->thumbnailWidth = $thumbnailWidth;

Expand Down
8 changes: 4 additions & 4 deletions tests/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -65,7 +65,7 @@
->setResolution(72)
->getImageData('test.jpg')
->getImageResolution();

expect($image['x'])->toEqual(72);
expect($image['y'])->toEqual(72);
});
Expand All @@ -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);
});
});

0 comments on commit 9b8d5ba

Please sign in to comment.