攻防世界_misc_碎纸机11
环境
碎纸机11,图片拼接
flag{You Can Repair A Picture From Splices Baesd On Entropy}
wp
解压发现图片需要拼接,通过修改时间升序拼接,顺序才是正确的
python
from PIL import Image
import os
# 定义要拼接的文件夹路径
folder_path = './images'
# 获取文件夹中所有的图片文件名,按修改时间进行升序排序
image_files = sorted(filter(lambda f: f.endswith('.jpg') or f.endswith('.png'), os.listdir(folder_path)),
key=lambda f: os.path.getmtime(os.path.join(folder_path, f)))
# 计算拼接后的图片宽度和高度
widths, heights = zip(*(Image.open(os.path.join(folder_path, img)).size for img in image_files))
total_width = sum(widths)
max_height = max(heights)
# 创建一个新的空白图片,宽度为拼接后的图片宽度,高度为最高图片的高度
new_image = Image.new('RGB', (total_width, max_height))
# 将要拼接的图片粘贴到新的空白图片上
x_offset = 0
for img in image_files:
new_image.paste(Image.open(os.path.join(folder_path, img)), (x_offset, 0))
x_offset += Image.open(os.path.join(folder_path, img)).size[0]
# 保存拼接后的图片
new_image.save('out.png')
扫描即可,扫描不出来可以ps调一下


浙公网安备 33010602011771号