Fixed: Create versions of PDF image
This commit is contained in:
parent
ffa83f8e9a
commit
5cb79c75a6
|
@ -10,7 +10,7 @@ class PdfCompressor extends Compressor {
|
||||||
|
|
||||||
protected function getExtension(): string
|
protected function getExtension(): string
|
||||||
{
|
{
|
||||||
return 'jpg';
|
return 'pdf.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function make(string $path): array
|
public function make(string $path): array
|
||||||
|
@ -28,7 +28,7 @@ class PdfCompressor extends Compressor {
|
||||||
|
|
||||||
private function extractImage(string $pdf): string
|
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);
|
exec('convert -density 150 '.escapeshellarg($pdf.'[0]').' -quality 90 '.escapeshellarg($file), $output, $r);
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,7 @@ class ResizerTest extends TestCase
|
||||||
Event::fire('media.file.upload', [null, '/pages/test.png', null]);
|
Event::fire('media.file.upload', [null, '/pages/test.png', null]);
|
||||||
|
|
||||||
$this->assertHasFile('pages/test-100x100.png');
|
$this->assertHasFile('pages/test-100x100.png');
|
||||||
|
$this->assertHasFile('pages/test-500x500.png');
|
||||||
$this->assertFileCount(2, 'pages');
|
$this->assertFileCount(2, 'pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,15 +228,18 @@ class ResizerTest extends TestCase
|
||||||
public function testGeneratePdfImages(): void
|
public function testGeneratePdfImages(): void
|
||||||
{
|
{
|
||||||
Setting::set('folders', [['folder' => '/pages']]);
|
Setting::set('folders', [['folder' => '/pages']]);
|
||||||
Setting::set('sizes', []);
|
Setting::set('sizes', [['name' => 'testas', 'aspect_ratio' => '1x1']]);
|
||||||
Setting::set('breakpoints', []);
|
Setting::set('breakpoints', [200]);
|
||||||
|
|
||||||
$media = MediaLibrary::instance();
|
$media = MediaLibrary::instance();
|
||||||
$media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf'));
|
$media->put('/pages/test.pdf', file_get_contents(__DIR__.'/stub/dummy.pdf'));
|
||||||
Event::fire('media.file.upload', [null, '/pages/test.pdf', null]);
|
Event::fire('media.file.upload', [null, '/pages/test.pdf', null]);
|
||||||
|
|
||||||
$this->assertHasFile('pages/test-1275x1650.jpg');
|
$this->assertHasFile('pages/test-1275x1650.pdf.jpg');
|
||||||
$this->assertFileCount(1, 'pages');
|
$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');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue