Hi mấy đại ca ! có cách nào gửi string image sang Python ko ạ em có thử test nhưng ko thành công
FILE index.php:
function CURL_IMG($url){
$data = [];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT,20);
$data["raw"] = curl_exec($ch);
if (curl_errno($ch)){
$data["error"] = curl_errno($ch);
}else{
$info = curl_getinfo($ch);
$data["file_size"] = $info["size_download"];
$data["ext"] = explode("/",$info["content_type"])[1];
}
curl_close($ch);
return $data;
}
$curl = CURL_IMG("https://devilchan.com/public/pictures/onii-chan-asa-made-zutto-gyu-tte-shite-onami-shumi_15854407323165_2436x3500.png")["raw"];
echo shell_exec("index.py " . $curl);
file index.py:
import sys
import numpy as np
import cv2
image = sys.argv[1]
open('image.png', 'wb').write(image)
Tks mấy đại ca ^^