ChrisHardie / printable-pdf-newspaper

WordPress plugin to generate a printable PDF newspaper from post content
GNU General Public License v2.0
7 stars 1 forks source link

TCPDF error: "Unable to get the size of the image" #32

Closed ChrisHardie closed 3 years ago

ChrisHardie commented 4 years ago

A user reported that when trying to generate the PDF, they get this error:

TCPDF ERROR: [Image] Unable to get the size of the image

The image in question was a valid JPG file and it worked fine in my local testing.

Some similar reports elsewhere about this tcpdf error indicate an issue with relative vs absolute file path names.

ChrisHardie commented 4 years ago

This error message doesn't appear in the TCPDF library itself AFAIK, so I think it's related to an underlying filesystem/network operation where the image can't be retrieved. I can imagine some hosts are set up intentionally or by accident to prevent curl/fetch requests from the same host to itself, so maybe that's it. Asking for more details from the user.

ChrisHardie commented 3 years ago

Received another report of this error message from a user when turning on the display of post thumbnails in the generated PDF:

TCPDF ERROR: [Image] Unable to get the size of the image: https:...

Confirmed that the images themselves were available and otherwise valid. Asked the user for host information; I hadn't heard back from the previous user mentioned above.

ChrisHardie commented 3 years ago

I was able to reproduce this today with the attached image. a67032fa-4696-3f02-aa9a-961627db7dd0-2

ChrisHardie commented 3 years ago

For at least my local reproduction, based on https://stackoverflow.com/a/28007106/4891448 wondering if this is because of a self-signed SSL certificate.file_get_contents() failed until I made an exception for verifying the SSL certificate (per https://stackoverflow.com/questions/1975461/how-to-get-file-get-contents-to-work-with-https). But, I don't think the original user error reports were on sites with self-signed certs...

Confirmed via xdebug that this is the error happening for me:

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed