From 56d194a4300610a17cc3c6682aaf63f039e9c4ab Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期日, 03 八月 2025 16:11:37 +0800
Subject: [PATCH] add matanyone-better auqliaty than robustvideomatting

---
 auto_media_publisher/utils/utils_text2image_pollinations.py |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/auto_media_publisher/utils/utils_text2image_pollinations.py b/auto_media_publisher/utils/utils_text2image_pollinations.py
index f78411b..6f107e5 100644
--- a/auto_media_publisher/utils/utils_text2image_pollinations.py
+++ b/auto_media_publisher/utils/utils_text2image_pollinations.py
@@ -12,6 +12,7 @@
     POLLINATIONS_DEFAULT_HEIGHT ,
     POLLINATIONS_DEFAULT_MODEL,
 )
+from .utils_images import resize_and_crop_center_any
 
 
 class Text2ImageGenerator:
@@ -61,12 +62,12 @@
             try:
                 response = requests.get(url, timeout=30)
                 response.raise_for_status()
-                return response.content
+                return resize_and_crop_center_any(response.content,self.width,self.height)
             except Exception as e:
                 print(f"[!] 璇锋眰绗� {attempt} 娆″け璐ワ細{e}")
         return None
 
-    def generate_image(self, prompt: str, filename: str = None) -> str:
+    def generate_image_with_trans(self, prompt: str, filename: str = None) -> str:
         if not prompt.strip():
             raise ValueError("鎻愮ず璇嶄笉鑳戒负绌�")
 
@@ -90,7 +91,31 @@
         print(f"[鉁揮 鍥剧墖宸蹭繚瀛橈細{abs_path}")
         return abs_path
     
-    def generate_image_to_stream(self, prompt: str) -> BytesIO:
+    def generate_image_without_trans(self, prompt: str, filename: str = None) -> str:
+        if not prompt.strip():
+            raise ValueError("鎻愮ず璇嶄笉鑳戒负绌�")
+
+        url = self.build_url(prompt)
+        print(url)
+
+        content = self._fetch_with_retry(url)
+        if content is None:
+            return None
+
+        if not filename:
+            now = datetime.datetime.now()
+            filename = now.strftime("%Y%m%d%H%M%S") + ".png"
+        if not filename.lower().endswith(".png"):
+            filename += ".png"
+
+        with open(filename, "wb") as f:
+            f.write(content)
+
+        abs_path = os.path.abspath(filename)
+        print(f"[鉁揮 鍥剧墖宸蹭繚瀛橈細{abs_path}")
+        return abs_path
+    
+    def generate_image_with_trans_to_stream(self, prompt: str) -> BytesIO:
         if not prompt.strip():
             raise ValueError("鎻愮ず璇嶄笉鑳戒负绌�")
 

--
Gitblit v1.9.1