当前位置: 首页 > news >正文

网站策划案需要包括哪些刷神马关键字排名软件

网站策划案需要包括哪些,刷神马关键字排名软件,wordpress插件中文版下载,洛南网站建设在PYTHON中用zlib模块对文本进行压缩长度,写入图片的EXIF中,并在C#中读取EXIF后用SharpZipLib进行解压缩获取压缩前文本。 PS:当压缩后的字节数组长度为单数时,无法写入EXIF的XPComment中,需要在后面增加一个以utf-8编码的空格&a…

在PYTHON中用zlib模块对文本进行压缩长度,写入图片的EXIF中,并在C#中读取EXIF后用SharpZipLib进行解压缩获取压缩前文本。

PS:当压缩后的字节数组长度为单数时,无法写入EXIF的XPComment中,需要在后面增加一个以utf-8编码的空格, 使其在原基础上在1变为双数 。另外,解压时要根据压缩时的编码选择对应的解压编码。

PYTHON代码

def save_file(args):#增加在主图片主题属性中增加CV2抠图返回的点 START_, cnt_original, _ = cv2.findContours(synthetic, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)contours_list = cnt_original[0].tolist()process_contours_list = []for list in contours_list:process_contours_list.append(list[0])# 数据格式 [[12,33],[1232,212],[1233,244].....]    # list转字符串process_contours_list_bytes = json.dumps(process_contours_list)   compress_contors = zlibCompress(process_contours_list_bytes)    exif_dict = piexif.load(image_name)if 'exif' not in image.info.keys():software = ""copyright = ""XPComment = ""else:exifData = piexif.load(image.info['exif'])exifData = exifData['0th']software = exifData[piexif.ImageIFD.Software]copyright = exifData[piexif.ImageIFD.Copyright]XPComment = exifData[piexif.ImageIFD.XPComment]zeroth_ifd = {piexif.ImageIFD.XPSubject: compress_contors,piexif.ImageIFD.XPComment: XPComment,piexif.ImageIFD.Software:software,piexif.ImageIFD.Copyright:copyright}# exif_dict['0th'] = zeroth_ifdexif_dict = {"0th": zeroth_ifd}# print(exif_dict)exif_bytes = piexif.dump(exif_dict)img.save(filename + "_s.jpg", format="JPEG", quality=quality, dpi=dpi,exif=exif_bytes)#用Zlib进行压缩        
# 参数为字符串,返回为bytes[]
# 当压缩后的字节数组长度为单数时,无法写入EXIF的XPComment中,需要在后面增加一个以utf-8编码的空格,
# 使其在原基础上在1变为双数            
def zlibCompress(data):compress_contors = zlib.compress(data.encode('utf-16'))if (len(compress_contors) % 2 != 0):add_byte = bytes(' ',encoding='utf-8')compress_contors += add_byte# tem_data = data + '.'# tem_data = tem_data.encode('utf-16')# compress_contors = zlib.compress(tem_data)return compress_contors 

C#读取并用SharpZipLib库 进行解压解压文本

using MetadataExtractor;
using System;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.Zip.Compression;//读取图片EXIF并解压内容
private void button6_Click(object sender, EventArgs e)
{try{string filename = "G://test/test/_200_s.jpg";if (File.Exists(filename)){StringBuilder sb = new StringBuilder();IReadOnlyList<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(filename);foreach (MetadataExtractor.Directory directory in directories){if (directory.HasTagName(40095)){byte[] resDes = directory.GetByteArray(40095);byte[] res0 = SharpZipLibDecompress(resDes);string result = System.Text.Encoding.Unicode.GetString(res0);//根据压缩时的编码选择对应的解压编码//string result = System.Text.Encoding.UTF8.GetString(res0);Console.WriteLine(result);}}}}catch (Exception ex){System.Windows.Forms.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);}
}//用SharpZipLib进行解压
public static byte[] SharpZipLibDecompress(byte[] data){MemoryStream compressed = new MemoryStream(data);MemoryStream decompressed = new MemoryStream();InflaterInputStream inputStream = new InflaterInputStream(compressed);inputStream.CopyTo(decompressed);return decompressed.ToArray();}

http://www.sczhlp.com/news/150291/

相关文章:

  • 龙口建网站wordpress上传中文图片不显示
  • 网站建设制作品牌公司深圳比较好的设计工作室
  • 强化学习、深度学习、大模型、智能体
  • Node生态中最优雅的数据库事务处理机制
  • 详细介绍:扒透 STL 底层!map/set 如何封装红黑树?迭代器逻辑 + 键值限制全手撕----《Hello C++ Wrold!》(23)--(C/C++)
  • 网站制作把图片做背景品牌注册查询官网入口
  • 连云港市赣榆区建设局网站杭州logo设计公司哪家好
  • 酒店网站的规划与建设网站如何集成微信支付
  • 上海网站制作网站广州卓天跨境电商网站
  • 大连鼎信网站建设公司地址广州越秀区租房子多少钱一个月
  • 举例说明网络营销的概念白山seo
  • 电子商务网站的后台管理系统中国楼市最新消息2022
  • ArcGIS 公众号推荐
  • 跨网文件交换系统:数字化时代企业与机构的数据安全传输利器
  • 期货市场API对接完全指南:实时行情获取与实战应用
  • 有什么网站可以接手工加工做信誉好的扬州网站建设
  • 石家庄网站制作报价原创主题 wordpress
  • 2016年做网站能赚钱wordpress do_
  • 中小企业网站提供了什么网站建立好如何做seo
  • 南宁市网站建设公司建设文明网站包括
  • 哈尔滨建站流程网站必须做等保合规
  • 公司网站建设济南兴田德润厉害吗网页制作软件是应用软件吗
  • 小辣椒昆明网站开发建筑设计图纸
  • 多站点wordpress简数采集器代理网站开发
  • 哪个网站做海报好小程序商城开发稳定吗
  • 唐山有制作网站的没电脑网页游戏排行
  • 湖南做网站 就问磐石网络专业网站如何做微信推广方案
  • Tomcat使用redis管理session
  • NOC片上网络总线初探
  • AT_agc037_c [AGC037C] Numbers on a Circle