【发布时间】:2016-09-12 11:06:02
【问题描述】:
当我尝试在 PHP 中调用 imagepng 时遇到 SSL 错误。
Message: imagecreatefrompng(): SSL operation failed with code 1
我知道在使用 get_put_contents() 时可以禁用 SSL 验证,但您可以使用 imagepng 来执行此操作吗?谢谢。
【问题讨论】:
标签: php image ssl image-processing
当我尝试在 PHP 中调用 imagepng 时遇到 SSL 错误。
Message: imagecreatefrompng(): SSL operation failed with code 1
我知道在使用 get_put_contents() 时可以禁用 SSL 验证,但您可以使用 imagepng 来执行此操作吗?谢谢。
【问题讨论】:
标签: php image ssl image-processing
不是直接的,但您应该可以将file_get_contents 与imagecreatefromstring 结合起来,例如
$context = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$url = 'https://www.google.co.uk/images/nav_logo242.png';
$response = file_get_contents($url, false, stream_context_create($context));
$img = imagecreatefromstring($response);
【讨论】: