public static function imageExists($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if(curl_exec($ch)!==FALSE)
{
return true;
}
else
{
return false;
}
}
public static function isJson($string)
{
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}
public static function get_webp_from_advancedplugins($path = NULL, $image_type = 'image_file_b64', $image_quality = 85)
{
if($path == NULL)
return false;
$ch = curl_init();
$data = array(
'action' => 'convert2webp',
'q' => $image_quality,
'token' => '63etrbf3yhrtbsgwsd',
$image_type => $path,
);
curl_setopt($ch, CURLOPT_URL,"https://api.advancedplugins.com");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: image/jpeg"));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
$server_output = curl_exec($ch);
curl_close ($ch);