diff --git a/compressors/PdfCompressor.php b/compressors/PdfCompressor.php index f1185c3..595a8c4 100644 --- a/compressors/PdfCompressor.php +++ b/compressors/PdfCompressor.php @@ -10,7 +10,7 @@ class PdfCompressor extends Compressor { protected function getExtension(): string { - return 'jpg'; + return 'pdf.jpg'; } public function make(string $path): array @@ -28,7 +28,7 @@ class PdfCompressor extends Compressor { private function extractImage(string $pdf): string { - $file = $this->tmpPath().'.jpg'; + $file = $this->tmpPath().'.'.$this->getExtension(); exec('convert -density 150 '.escapeshellarg($pdf.'[0]').' -quality 90 '.escapeshellarg($file), $output, $r); diff --git a/tests/ResizerTest.php b/tests/ResizerTest.php index be0e6c3..bb440d6 100644 --- a/tests/ResizerTest.php +++ b/tests/ResizerTest.php @@ -192,6 +192,7 @@ class ResizerTest extends TestCase Event::fire('media.file.upload', [null, '/pages/test.png', null]); $this->assertHasFile('pages/test-100x100.png'); + $this->assertHasFile('pages/test-500x500.png'); $this->assertFileCount(2, 'pages'); } @@ -227,15 +228,18 @@ class ResizerTest extends TestCase public function testGeneratePdfImages(): void { Setting::set('folders', [['folder' => '/pages']]); - Setting::set('sizes', []); - Setting::set('breakpoints', []); + Setting::set('sizes', [['name' => 'testas', 'aspect_ratio' => '1x1']]); + Setting::set('breakpoints', [200]); $media = MediaLibrary::instance(); $media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf')); Event::fire('media.file.upload', [null, '/pages/test.pdf', null]); - $this->assertHasFile('pages/test-1275x1650.jpg'); - $this->assertFileCount(1, 'pages'); + $this->assertHasFile('pages/test-1275x1650.pdf.jpg'); + $this->assertHasFile('pages/test-1275x1275.pdf.jpg'); + $this->assertHasFile('pages/test-200x259.pdf.jpg'); + $this->assertHasFile('pages/test-200x200.pdf.jpg'); + $this->assertFileCount(4, 'pages'); } }