Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.84k stars 1.5k forks source link

PDF Support #1282

Closed juanborras closed 7 months ago

juanborras commented 7 months ago

Describe the feature you'd like I would love to do this:

// Just for one page pdf $imgageManager = new ImageManager(Driver::class); $pdf= $imgageManager->read(storage_path('app/') . $pdfFile); $pdf->toJpeg(100)->save(storage_path('app/') . $pdfFile . '.JPG');

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

olivervogel commented 7 months ago

This is already possible if you use the Imagick driver class, as it can read all formats supported by Imagick itself. The 'toJpeg' can be omitted in this case.

use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;

// transform first page of pdf to jpeg with imagick driver
ImageManager::withDriver(ImagickDriver::class)
    ->read('test.pdf')
    ->save('test.jpg', quality: 100);

However, output is only possible with the formats supported by Intervention Image. Since the target format is JPEG in your case, this should not be a problem.

Official support for PDF is not planned at this time. The focus of this library is more on pixel-based images.