搜索
简帛阁>技术文章>在图片上加字符-base64转图片-图片转base64

在图片上加字符-base64转图片-图片转base64

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>get chinaz info</title>

<link rel="stylesheet" type="text/css" href="/img/css/admin.css" />
<script type="text/javascript" src="/img/js/jquery-1.4.2.min.js"></script>
</head>
<body>

</form>
<!-- <img src="https://img-blog.csdnimg.cn/2022010616404780876.jpeg">

<?php 
$base64_image_content = "https://img-blog.csdnimg.cn/2022010616404780876.jpeg";

$name = date('Y-m-d H:i:s',time());
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2]; 
$new_file = "test.{$type}"; 
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){ 
echo '新文件保存成功:', $new_file; 
}
}

 

 

 


$dst_path = 'test.jpg';
//创建图片的实例
$dst = imagecreatefromjpeg($dst_path);
//打上文字
$font = 'simsun.ttc';//字体
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$black = imagecolorallocate($dst, 0x00, 0x00, 0x00);//字体颜色
imagefttext($dst, 20, 0, 5, 50, $black, $font, '1');
imagefttext($dst, 20, 0, 85, 50, $black, $font, '2');
imagefttext($dst, 20, 0, 155, 50, $black, $font, '3');
imagefttext($dst, 20, 0, 225, 50, $black, $font, '4');
imagefttext($dst, 20, 0, 5, 130, $black, $font, '5');
imagefttext($dst, 20, 0, 85, 130, $black, $font, '6');
imagefttext($dst, 20, 0, 155, 130, $black, $font, '7');
imagefttext($dst, 20, 0, 225, 130, $black, $font, '8');
imagejpeg($dst,'3.jpg');
//输出图片
//list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
//switch ($dst_type) {
// case 1://GIF
// header('Content-Type: image/gif');
// imagegif($dst);
// break;
// case 2://JPG
// header('Content-Type: image/jpeg');
// imagejpeg($dst);
// break;
// case 3://PNG
// header('Content-Type: image/png');
// imagepng($dst);
// break;
// default:
// break;
//}
imagedestroy($dst);
?>

 


</body>
</html>

  

转载于:https://www.cnblogs.com/yixianyixian/p/4342386.html

<!DOCTYPEhtmlPUBLIC//W3C//DTDXHTML10Transitional//ENhttp://wwww3org/TR/xhtml1/DTD/xhtml1transitio
前端imageBuffer设置图片src(后端到前端直传buffer)本质为bufferbase64letbytesnewUint8Array(imageBufferdata);letdata;le
lt;!DOCTYPEhtml><htmllangen><head><metacharsetUTF8><title>图片base64</
<!_NextPart_000_0000_01CA9F59AFB45FE0ContentType:image/jpgContentTransferEncoding:base64ContentLo
概念:Base64加密方式是将三个八位的字节转化为四个六位的字节(不足八位的高位补00),3*84*6;,所以base64加密过后的内容比原来的大三分之一;举例:加密“ace”,ace转化为二进制为:
小程序中,有些业务要用到图片base64wxchooseImage({success:res>{wxgetFileSystemManager()readFile({filePath:rest
Java代码图片字符串互/***将base64字符串转成图片*TODO*@paramimgStrbase64图片字符串*@parampath目标输出路径*@return*/publicstatic
情景:如图该请求返回一张图片,我该如何显示页面呢?代码如下:transformArrayBufferToBase64(buffer){varbinary;varbytesnewUint8Array
1问题描述小程序项目需要后端接口提供base64流的图片,对于H5的语法,前面拼接后面的代码即可:data:image/png;base64,先看后台代码:@RestController@Reques
*coding:utf8*importbase64withopen(/home/chaowei/1png,rb)asf:b64encode是编码,b64decode是解码base64_database