一篇读懂原道(原道照相机经纬照相机下载)
元道经纬相机是一款时间和地点信息真实的专业的现场拍照水印相机,元道经纬相机由深圳市元道通信技术有限公司自主设计研发,现场拍照片或拍视频实时GPS
元道经纬相机是一款时间和地点信息真实的专业的现场拍照水印相机,元道经纬相机由深圳市元道通信技术有限公司自主设计研发,现场拍照片或拍视频实时GPS定位,自动加载经纬度、时间、地址,海拔、天气、IMEI、logo等水印信息,可用于巡检维修、项目管理、现场取证、考勤打卡、拍照留痕等不同工作场景,帮助用户轻松记录工作,高效进行团队管理。
作为python爱好者,当然不能错过这样好的模仿学习机会,今天就尝试模拟出原道相机的水印效果。(仅供学习使用,切勿用作非法用途,否则后果自负)
以下是实现代码from PIL import Image, ImageDraw, ImageFont defadd_text_to_image(image, text, position, font_size=
12, text_color=(255, 255, 255)): font = ImageFont.truetype("simsun.ttc", font_size) draw = ImageDraw.Draw(image) draw.text(position, text, font=font, fill=text_color)
defadd_hollow_watermark_to_image(image, text, font_size=36, outline_color=(0, 0, 0), outline_width=1)
: watermark_font = ImageFont.truetype("STCAIYUN.TTF", font_size) # 使用华文彩云字体 text_width, text_height = watermark_font.getsize(text)
# Create a new image with transparent background watermark_image = Image.new("RGBA", (text_width +
2 * outline_width, text_height + 2 * outline_width), (0, 0, 0, 0)) draw = ImageDraw.Draw(watermark_image)
# Draw the outlinefor x_offset in range(-outline_width, outline_width + 1): for y_offset in range(-outline_width, outline_width +
1): draw.text((outline_width + x_offset, outline_width + y_offset), text, font=watermark_font, fill=outline_color)
return watermark_image defmain(): image_path = "C:\\Users\\李武第\\Desktop\\3.png" latitude =
"xxx" longitude = "xxx" address = "xxx" timestamp = "xxx" altitude = "xxx米" weather =
"xxx" note = "xxx" image = Image.open(image_path) # Add text information to the image text_info =
f"经度:{longitude}\n纬度:{latitude}\n地址:{address}\n时间:{timestamp}\n海拔:{altitude}\n天气:{weather}\n备注:{note}
" text_position = (40, image.height - 180) # Adjusted position with some padding add_text_to_image(image, text_info, text_position)
# Add hollow watermark to the center of the image watermark_text = "现场拍照" watermark_image = add_hollow_watermark_to_image(image, watermark_text, outline_color=(
0, 0, 0), outline_width=0) # 调整为更细的边框 watermark_position = ((image.width - watermark_image.width) //
2, (image.height - watermark_image.height) // 2) image.paste(watermark_image, watermark_position, watermark_image) image.save(
"output_image.png") image.show() if __name__ == "__main__": main()
之后我会在我的python包PaperCrawlerUtil中加入更加便捷详细的水印功能,敬请关注。
- 标签:
- 编辑:李松一
- 相关文章
-
zuo是什么?左氧氟沙星滴眼液?
这款专为医生打造的输入法拥有海量医疗词库,拥有超10万个包括中、西医在内的医学词汇,还针对医生场景进行了优化。…
-
惟一是什么?惟一拼音?
用一首歌的时间陪你入睡。
- 惟一是什么?惟一拼音?
- 心的笔顺是什么?心的笔顺是什么写的?
- 高洁是什么?高洁丝卫生巾安全吗?
- 驼峰是什么?驼峰桥的标志图片?
- 电场强度是什么?电场强度的定义?