This commit is contained in:
dongchangxi committed 2025-01-03 17:24:52 +08:00
1 parent 916c0e6e15
commit 3c25b275d2
2 files changed
+11 -60

No files matched your search

+5 -5
View File
@@ -50,11 +50,11 @@ def get_photo2_align_info(pid):
#下载照片 #下载照片
libs.down_from_oss_photo2(config.oss_bucket, config.workdir, pid) libs.down_from_oss_photo2(config.oss_bucket, config.workdir, pid)
else: else:
pass
# #移除文件夹 #移除文件夹
# shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True) shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True)
# #下载照片 #下载照片
# libs.down_from_oss_photo2(config.oss_bucket, config.workdir, pid) libs.down_from_oss_photo2(config.oss_bucket, config.workdir, pid)
#判断是否存在该目录 #判断是否存在该目录
print(f"影棚号:{psid} , {config.oss_bucket.object_exists(f'xmps_new_studio_rate/{psid}/')}") print(f"影棚号:{psid} , {config.oss_bucket.object_exists(f'xmps_new_studio_rate/{psid}/')}")
+6 -55
View File
@@ -6,13 +6,6 @@ if platform.system() == 'Windows':
else: else:
sys.path.append('/data/deploy/make3d/make2/libs/') sys.path.append('/data/deploy/make3d/make2/libs/')
import config, libs, libs_db
import cv2
import numpy as np
from PIL import Image
from PIL.ExifTags import TAGS
import piexif
#检测是否存在 rate_xmps 文件,如果没有则要创建该影棚对应的rate_xmps文件 #检测是否存在 rate_xmps 文件,如果没有则要创建该影棚对应的rate_xmps文件
def check_rate_xmps(pid): def check_rate_xmps(pid):
pid = str(pid) pid = str(pid)
@@ -28,55 +21,13 @@ def clearExifAndRotate(imagePath, rotate=90):
return return
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片exif信息清除并且旋转...') print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {imagePath} 图片exif信息清除并且旋转...')
# img = Image.open(imagePath)
# print(img.info)
# # 清除 EXIF 信息
# img.info = {} # 清除 EXIF 信息
# # 旋转图片 180 度
# img = img.rotate(180)
# # 保存处理后的图片
# img.save(imagePath)
clear_exif(imagePath,imagePath)
rotate_image(imagePath, 90, imagePath)
# 打开图像 # 打开图像
# with Image.open(imagePath) as img: with Image.open(imagePath) as img:
# # 使用RGB模式打开图像来丢弃可能存在的EXIF信息 # 使用RGB模式打开图像来丢弃可能存在的EXIF信息
# img = img.convert("RGB") img = img.convert("RGB")
# img = img.rotate(rotate) img = img.rotate(rotate,expand=True)
# # 保存图像,保存时不会带有原始的任何元数据 # 保存图像,保存时不会带有原始的任何元数据
# img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数 img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数
# 1. 清除 EXIF 信息
def clear_exif(image_path, output_path):
# 使用 Pillow 打开图像并清除 EXIF
image = Image.open(image_path)
# 创建不包含EXIF信息的副本
image_no_exif = Image.new(image.mode, image.size)
image_no_exif.paste(image, (0, 0))
# 保存不包含EXIF的图像
image_no_exif.save(output_path)
# 2. 旋转图像
def rotate_image(image_path, angle, output_path):
# 使用 OpenCV 读取图像
image = cv2.imread(image_path)
# 获取图像的中心
center = (image.shape[1] // 2, image.shape[0] // 2)
# 获取旋转矩阵
rotation_matrix = cv2.getRotationMatrix2D(center, angle, 1.0)
# 执行旋转
rotated_image = cv2.warpAffine(image, rotation_matrix, (image.shape[1], image.shape[0]))
# 保存旋转后的图像
cv2.imwrite(output_path, rotated_image)
#如果老影棚没有做过旋转坐标的照片的,则要做一次旋转坐标 #如果老影棚没有做过旋转坐标的照片的,则要做一次旋转坐标
def rateImages(pid): def rateImages(pid):