我正在使用 Microsoft Azure 云,需要在那里上传图像。它的类上传方法 putBlob() 和 putBlobData() 需要数据本身(不是资源)或目录字符串作为参数,在图像实际写入 Blob 之前,这些方法都不可用。
$fp = fopen($tmp_name, 'r');
$data = fread($fp, filesize($tmp_name));
fclose($fp);
//Setup watermark destination
$new_watermarked_image_name = "watermark.jpg";
// Create image resources
$image = imagecreatefromstring($data);
$watermark = imagecreatefrompng('images/watermark_large.png');
$copyright = imagecreatefrompng('images/copyright.png');
// Merge image resource s
$image = overlay_watermark_full_size($image, $watermark);
$image = overlay_watermark_lower_right($image, $copyright);
imagejpeg($image, $new_watermarked_image_name, 100);
//put original image
$AzureStorageBlob->putBlob("uploads", "name", $tmp_name);
//put watermarked image
$AzureStorageBlob->putBlobData("uploads", "name", ?); // ? needs to be data