A proof-of-concept for extracting images from PDF files with SetaPDF.

dev-main 2022-07-26 15:18 UTC

This package is auto-updated.

Last update: 2023-05-27 10:47:06 UTC


This package is a proof of concept to extract images from PDFs in pure PHP with the SetaPDF-Core component and an image render module. Currently, not all kinds of images are supported. This is also very dependent on your used image renderer library. GD and Imagick are currently implemented. We recommend you to use Imagick as it's more feature complete as GD but may be a little harder to install.


This package is developed and tested on PHP >= 7.4.

You'll need an active license of the SetaPDF-Core component.

Requirements of the SetaPDF-Core component can be found here.


This example here extracts all images from the first page of the pdf:

$document = SetaPDF_Core_Document::loadByFilename('your-pdf-file.pdf');
$images = \setasign\SetaPDF\ImageExtractor\ImageExtractor::getImagesByPageNo($document, 1);
foreach ($images as $imageData) {
    // if you're using imagick
    $imagick = \setasign\SetaPDF\ImageExtractor\ImageExtractor::toImage($imageData, ImageExtractor::IMAGE_RENDERER_IMAGICK);
    $image = $imagick->getImageBlob();
    echo '<img src="data:image/png;base64,' . base64_encode($image) . '"/>';

    // if you're using gd use this code instead
    $gd = ImageExtractor::toImage($imageData, ImageExtractor::IMAGE_RENDERER_GD);
    $image = ob_get_clean();
    echo '<img src="data:image/png;base64,' . base64_encode($image) . '"/>';


This package is open-sourced software licensed under the MIT license.