|
|
|
|
@ -7,7 +7,11 @@ else:
@@ -7,7 +7,11 @@ else:
|
|
|
|
|
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文件 |
|
|
|
|
def check_rate_xmps(pid): |
|
|
|
|
@ -33,15 +37,46 @@ def clearExifAndRotate(imagePath, rotate=90):
@@ -33,15 +37,46 @@ def clearExifAndRotate(imagePath, rotate=90):
|
|
|
|
|
# # 保存处理后的图片 |
|
|
|
|
# img.save(imagePath) |
|
|
|
|
|
|
|
|
|
clear_exif(imagePath,imagePath) |
|
|
|
|
rotate_image(imagePath, 90, imagePath) |
|
|
|
|
# 打开图像 |
|
|
|
|
with Image.open(imagePath) as img: |
|
|
|
|
# 使用RGB模式打开图像来丢弃可能存在的EXIF信息 |
|
|
|
|
img = img.convert("RGB") |
|
|
|
|
img = img.rotate(rotate) |
|
|
|
|
# 保存图像,保存时不会带有原始的任何元数据 |
|
|
|
|
img.save(imagePath, quality=100) # 对于JPEG,可以调整质量参数 |
|
|
|
|
# with Image.open(imagePath) as img: |
|
|
|
|
# # 使用RGB模式打开图像来丢弃可能存在的EXIF信息 |
|
|
|
|
# img = img.convert("RGB") |
|
|
|
|
# img = img.rotate(rotate) |
|
|
|
|
# # 保存图像,保存时不会带有原始的任何元数据 |
|
|
|
|
# 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): |
|
|
|
|
|