feat 结果图宽度自适应
fix
This commit is contained in:
@@ -97,9 +97,9 @@ def process_object(cfg, process_id, total):
|
||||
# uploaded_images.append({'image_obj': layer['pattern_image'], 'image_url': layer['pattern_image_url'], 'image_type': 'pattern_image'})
|
||||
# if 'mask' in layer.keys() and layer['mask'] is not None and layer['mask_url'] is not None:
|
||||
# uploaded_images.append({'image_obj': layer['mask'], 'image_url': layer['mask_url'], 'image_type': 'mask'})
|
||||
|
||||
layers, new_size = update_base_size_priority(layers, body_size)
|
||||
# 合成
|
||||
items_response['synthesis_url'] = synthesis(layers, body_size, basic_info)
|
||||
items_response['synthesis_url'] = synthesis(layers, new_size, basic_info)
|
||||
|
||||
for lay in layers:
|
||||
items_response['layers'].append({
|
||||
@@ -177,3 +177,19 @@ def upload_images(image_obj):
|
||||
rgba_image[rgba_image[:, :, 0] == 0] = [0, 0, 0, 0]
|
||||
req = oss_upload_image(bucket=bucket_name, object_name=object_name, image_bytes=cv2.imencode('.png', rgba_image)[1])
|
||||
return image_obj['image_url']
|
||||
|
||||
|
||||
def update_base_size_priority(layers, size):
|
||||
# 计算透明背景图片的宽度
|
||||
min_x = min(info['position'][1] for info in layers)
|
||||
x_list = []
|
||||
for info in layers:
|
||||
if info['image'] is not None:
|
||||
x_list.append(info['position'][1] + info['image'].width)
|
||||
max_x = max(x_list)
|
||||
new_width = max_x - min_x
|
||||
new_height = 700
|
||||
# 更新坐标
|
||||
for info in layers:
|
||||
info['position'] = (info['position'][0], info['position'][1] - min_x)
|
||||
return layers, (new_width, new_height)
|
||||
|
||||
Reference in New Issue
Block a user