Procházet zdrojové kódy

webp格式和avif格式

rambo před 5 měsíci
rodič
revize
4e5bae8014

+ 13 - 1
python/custom_plugins/plugins/detail_template/huilima/detail_huilima6.py

@@ -260,7 +260,7 @@ class DetailPicGet(DetailBase):
             bg_color=self.base_bg_color,
         )
         # tips = "一只鞋放置在向日葵花园的草地上,鞋子后面有一块石头,石头上还有一只小猫,鞋得前面还有一条小溪,这就要求鞋子的角度、材质、纹理保持不变,背景要求富有创意且有真实感"
-        tips = "The shoes are placed on a light green background.The sun shines from one side, creating a soft shadow effect, and the overall style is fresh and natural, suitable for summer wear. Keep the texture and material of this shoe intact"
+        tips = "The shoes are placed on a neutral beige tone background.The sun shines from one side, creating a soft shadow effect, and the overall style is fresh and natural, suitable for summer wear. Keep the texture and material of this shoe intact"
         imageGenerateResult = self.getAiGenerateScenes(image_path=pp_jpg.im, tips=tips)
         if imageGenerateResult == None:
             return PictureProcessing(im=self.add_pic(detailed_images))
@@ -279,6 +279,18 @@ class DetailPicGet(DetailBase):
         real_bg = real_bg.paste_img(top_img=text_image, base="cc", value=(0, 100))
         detailed_images.append(real_bg)
         detailed_images.append(imageGenerateResult)
+        tips = "The image showcases a half-body shot of a model dressed in a gray dress and white ankle socks. The model is taking a step forward, with one foot slightly ahead. The shoes are precisely fitted to the model's feet, ensuring they are neither too large nor too small, with a subtly elevated heel. The background is a simple neutral beige, creating a clean and distraction-free visual effect. Throughout the process, it is essential to preserve the original texture and style of the shoes, including their unique design features and material feel, making the shoes appear realistic and natural as if truly worn by the model."
+        imageGenerateResult = self.getAiGenerateScenes(image_path=pp_jpg.im, tips=tips)
+        if imageGenerateResult == None:
+            detailed_images.append(
+                PictureProcessing("RGB", (temp_bg.width, 300), self.base_bg_color)
+            )
+            return PictureProcessing(im=self.add_pic(detailed_images))
+        imageGenerateResult = imageGenerateResult.resize(value=temp_bg.width)
+        imageGenerateResult = imageGenerateResult.radius(
+            value=30, circular_pos=(1, 1, 1, 1)
+        )
+        detailed_images.append(imageGenerateResult)
         detailed_images.append(
             PictureProcessing("RGB", (temp_bg.width, 300), self.base_bg_color)
         )

+ 18 - 2
python/custom_plugins/plugins_mode/detail_generate_base.py

@@ -16,9 +16,10 @@ import shutil
 from service.base import get_images, check_path, get_image_mask
 from natsort import ns, natsorted
 # import math
-from PIL import ImageFont
+from PIL import ImageFont, ImageFile
 import settings
-
+ImageFile.LOAD_TRUNCATED_IMAGES = True
+Image.MAX_IMAGE_PIXELS = None
 
 class DetailBase(object):
     def __init__(self, goods_no, goods_no_value: dict, out_put_dir, windows=None, excel_data=None,
@@ -190,6 +191,21 @@ class DetailBase(object):
             if isinstance(pp, dict):
                 continue
             pp.im.save("{}/{}({}).png".format(detail_path, self.goods_no, str(index + 11).zfill(2)))
+            try:
+                pp.im.save(
+                    "{}/{}({}).avif".format(
+                        detail_path, self.goods_no, str(index + 11).zfill(2)
+                    ),
+                    "AVIF",
+                )
+                pp.im.save(
+                    "{}/{}({}).webp".format(
+                        detail_path, self.goods_no, str(index + 11).zfill(2)
+                    ),
+                    "WEBP",
+                )
+            except:
+                print('An exception occurred')
 
     def check_state_end(self):
         if self.windows is not None:

+ 2 - 2
python/detail_template_test.py

@@ -4,7 +4,7 @@ import settings
 settings.is_test_plugins = True
 
 
-from custom_plugins.plugins.detail_template.xinnuo.detail_xinnuo3 import (
+from custom_plugins.plugins.detail_template.huilima.detail_huilima6 import (
     DetailPicGet,
 )
 
@@ -14,7 +14,7 @@ for goods_no, value in data.items():
     d = DetailPicGet(
         goods_no=goods_no,
         goods_no_value=value,
-        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\xinnuo-3",
+        out_put_dir=r"C:\Development\project\python\CameraMachine\python\output\huilima-6",
         test=True,
     )
 print("生成成功")

+ 16 - 3
python/service/grenerate_main_image_test.py

@@ -598,13 +598,26 @@ class GeneratePic(object):
                         dpi=(300, 300),
                         _format="JPEG",
                     )
-                    # save_image_by_thread(image_bg, out_path, save_mode="jpg", quality=100, dpi=(300, 300), _format="JPEG")
-                    # image_bg.save(out_path, quality=100, dpi=(300, 300), format="JPEG")
+                # save_image_by_thread(image_bg, out_path, save_mode="jpg", quality=100, dpi=(300, 300), _format="JPEG")
+                # image_bg.save(out_path, quality=100, dpi=(300, 300), format="JPEG")
             else:
                 self.saver.save_image(
                     image=image_bg, file_path=new_file_path, save_mode="png"
                 )
-                # image_bg.save(out_path)
+            try:
+                image_bg.save(f"{file_without_suffix}_{imageSize}.avif", "AVIF")
+                image_bg.save(f"{file_without_suffix}_{imageSize}.webp", "WEBP")
+            except:
+              print('An exception occurred')
+            self.saver.save_image(
+                image=image_bg,
+                file_path=new_file_path,
+                save_mode="avif",
+                quality=None,
+                dpi=None,
+                _format="AVIF",
+            )
+            # image_bg.save(out_path)
 
         if output_queue is not None:
             output_queue.put(True)

+ 1 - 1
python/service/multi_threaded_image_saving.py

@@ -4,7 +4,7 @@ from concurrent.futures import ThreadPoolExecutor, Future
 from typing import List, Dict, Any
 import time
 from PIL import Image
-
+import pillow_avif
 
 class ImageSaver:
     instance = None