resize img to 224x224

This commit is contained in:
dongpd 2020-12-23 10:42:11 +07:00
parent 9cca411720
commit 999df32e09

View File

@ -381,7 +381,18 @@ class ListManagementController extends Controller {
$fileName = "face_" . $key . "_" . time() . ".png"; $fileName = "face_" . $key . "_" . time() . ".png";
$img = file_get_contents($value); $img = file_get_contents($value);
if ($img !== "null") { if ($img !== "null") {
file_put_contents($targetPath . "/" . $fileName, $img); $im = imagecreatefromstring($img);
$width = imagesx($im);
$height = imagesy($im);
$newwidth = 224;
$newheight = 224;
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$fileTarget = $targetPath . "/" . $fileName;
imagejpeg($thumb, $fileTarget);
imagedestroy($thumb);
imagedestroy($im);
// file_put_contents($fileTarget, $img);
$features = json_decode(common::requestToEngine("/get-feature", [ $features = json_decode(common::requestToEngine("/get-feature", [
"image_paths" => [ "image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"] ["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]