Skip to content

Identified Images cannot be converted to image due to invalid (?) content #774

@delovelady

Description

@delovelady

PLEASE HELP ME CANCEL/CLOSE THIS ISSUE

My original search was incorrect, and this is a duplicate (times about 10).

In this file, 18 images are identified. But the following code cannot convert any images:

$pdf = $parser->parseFile($pdfFile) ;
$images = $pdf->getObjectsByType('XObject', 'Image') ;
foreach ($images AS $imgKey => $pdfImage) {
    try {
        $image = @imagecreatefromstring($pdfImage->getContent()) ;
    } catch (Exception $e) {
        $image = false ;
    }
    if ($image)
        printf("Image[$imgKey] converted.\n") ;
    else
        printf("Image[$imgKey] could not be converted.\n") ;
}

The encoding here seems to be 'FlateDecode' for all images in this file. I did not find any help to lead me to believe this should not work. Is my approach incorrect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions