Renaming a data:image/webp;base64, file in php (Imagick)

会有一股神秘感。 提交于 2020-05-17 08:47:18

问题


Is there any way to rename the

data:image/webp;base64,base64_encode($thumbnail)

to

$IndPackProductImagesArray[0]

so that when someone right clicks to open in a new tab, there's a name instead of encoded text

Below is the code:

<?php
$image = new Imagick();
$image->readImage("images/industrial_packaging/".$IndPackProductImageDirName2."/".$IndPackProductImagesArray[0]);

$watermark = new Imagick();
$watermark->readImage("images/default_products_image_fg.webp");


$image->compositeImage($watermark, Imagick::COMPOSITE_DEFAULT, 0, 0);
$image->thumbnailImage(500, 500, true, true); 

header("Content-Type: image/" . $image->getImageFormat());

ob_start();
$thumbnail = $image->getImageBlob();
ob_get_contents();
ob_end_clean();
echo 
"
<img 
class=\"card-img-top\" 
src=\"data:image/webp;base64,".base64_encode($thumbnail)."\" 
style=\"background-image: url('images/default_products_image_bg.webp'); background-size:cover;\"
/>
";
?>  

Any help appreciated!

来源:https://stackoverflow.com/questions/61419943/renaming-a-dataimage-webpbase64-file-in-php-imagick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!