This commit is contained in:
foge
2026-01-15 18:40:38 +08:00
parent f7954683ed
commit 22dbedd9be
3 changed files with 41 additions and 42 deletions
+9 -9
View File
@@ -3,7 +3,7 @@ import shutil
import sys
def check_and_install_avifenc():
"""检查并自动安装avifenc"""
"""Check and automatically install avifenc"""
avifenc_paths = [
os.path.join(sys.prefix, "Scripts", "avifenc.exe"),
os.path.join(sys.prefix, "bin", "avifenc"),
@@ -17,18 +17,18 @@ def check_and_install_avifenc():
break
if not avifenc_exists:
print("⚠️ avifenc未找到,尝试自动安装...")
print("⚠️ avifenc not found, trying to install automatically...")
try:
from .install_avifenc import install_avifenc
install_avifenc()
except Exception as e:
print(f"❌ 自动安装失败: {e}")
print("📋 请手动安装avifenc:")
print("1. 访问: https://github.com/AOMediaCodec/libavif/releases")
print("2. 下载最新版本的avifenc (Windows x64)")
print("3. 解压zip文件")
print(f"4. 将avifenc.exe复制到: {os.path.join(sys.prefix, 'Scripts')}")
print("5. 重启ComfyUI")
print(f"❌ Automatic installation failed: {e}")
print("📋 Please manually install avifenc:")
print("1. Visit: https://github.com/AOMediaCodec/libavif/releases")
print("2. Download latest avifenc (Windows x64)")
print("3. Extract zip file")
print(f"4. Copy avifenc.exe to: {os.path.join(sys.prefix, 'Scripts')}")
print("5. Restart ComfyUI")
check_and_install_avifenc()
+11 -12
View File
@@ -4,31 +4,30 @@ import numpy as np
avif_path = r"D:\ai\ComfyUI-aki-v1.6-8180\ComfyUI\output\test_transparency.avif"
print(f"🔍 检查 AVIF 文件: {avif_path}")
print(f"🔍 Checking AVIF file: {avif_path}")
try:
img = Image.open(avif_path)
print(f"✅ 成功打开 AVIF 文件")
print(f" 模式: {img.mode}")
print(f" 大小: {img.size}")
print(f"✅ Successfully opened AVIF file")
print(f" Mode: {img.mode}")
print(f" Size: {img.size}")
if img.mode == 'RGBA':
img_array = np.array(img)
alpha_channel = img_array[:, :, 3]
print(f" Alpha范围: {alpha_channel.min()} - {alpha_channel.max()}")
print(f" 透明像素: {(alpha_channel < 128).sum()}/{alpha_channel.size}")
print(f" 透明像素占比: {(alpha_channel < 128).sum() / alpha_channel.size * 100:.2f}%")
print(f" Alpha range: {alpha_channel.min()} - {alpha_channel.max()}")
print(f" Transparent pixels: {(alpha_channel < 128).sum()}/{alpha_channel.size}")
print(f" Transparent pixel ratio: {(alpha_channel < 128).sum() / alpha_channel.size * 100:.2f}%")
# 检查是否有真正的透明区域
if (alpha_channel < 128).sum() > 0:
print("✅ AVIF 文件包含透明区域")
print("✅ AVIF file contains transparent areas")
else:
print("❌ AVIF 文件没有透明区域")
print("❌ AVIF file does not contain transparent areas")
else:
print(f"❌ AVIF 文件不是 RGBA 模式,而是 {img.mode}")
print(f"❌ AVIF file is not in RGBA mode, but {img.mode}")
except Exception as e:
print(f"❌ 错误: {e}")
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
+21 -21
View File
@@ -18,34 +18,34 @@ def get_avifenc_url():
raise ValueError(f"Unsupported system: {system}")
def install_avifenc():
print("📦 开始安装avifenc...")
print("📦 Starting avifenc installation...")
try:
url = get_avifenc_url()
print(f"📥 下载avifenc from: {url}")
print(f"📥 Downloading avifenc from: {url}")
with tempfile.TemporaryDirectory() as temp_dir:
zip_path = os.path.join(temp_dir, "avifenc.zip")
try:
urllib.request.urlretrieve(url, zip_path)
print("✅ 下载完成")
print("✅ Download completed")
except Exception as e:
print(f"❌ 下载失败: {str(e)}")
print("\n📋 手动下载步骤:")
print("1. 访问: https://github.com/AOMediaCodec/libavif/releases")
print("2. 下载最新版本的avifenc (Windows x64)")
print("3. 解压zip文件")
print(f"4. 将avifenc.exe复制到: {os.path.join(sys.prefix, 'Scripts')}")
print("5. 重启ComfyUI")
print(f"❌ Download failed: {str(e)}")
print("\n📋 Manual download steps:")
print("1. Visit: https://github.com/AOMediaCodec/libavif/releases")
print("2. Download latest avifenc (Windows x64)")
print("3. Extract zip file")
print(f"4. Copy avifenc.exe to: {os.path.join(sys.prefix, 'Scripts')}")
print("5. Restart ComfyUI")
return False
try:
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(temp_dir)
print("✅ 解压完成")
print("✅ Extraction completed")
except Exception as e:
print(f"❌ 解压失败: {str(e)}")
print(f"❌ Extraction failed: {str(e)}")
return False
avifenc_dir = os.path.join(temp_dir, "bin")
@@ -64,33 +64,33 @@ def install_avifenc():
src = os.path.join(avifenc_dir, file)
dst = os.path.join(scripts_dir, file)
shutil.copy2(src, dst)
print(f"✅ 复制 {file} 到 {scripts_dir}")
print(f"✅ Copied {file} to {scripts_dir}")
avifenc_found = True
if not avifenc_found:
print(f"❌ 未找到avifenc文件在 {avifenc_dir}")
print(f"📂 目录内容: {os.listdir(avifenc_dir)}")
print(f"❌ avifenc file not found in {avifenc_dir}")
print(f"📂 Directory contents: {os.listdir(avifenc_dir)}")
return False
avifenc_path = os.path.join(scripts_dir, "avifenc")
if os.path.exists(avifenc_path):
os.chmod(avifenc_path, 0o755)
print(f"✅ avifenc安装成功!")
print(f"📁 安装路径: {avifenc_path}")
print(f"🔧 请确保 {scripts_dir} 在PATH中")
print(f"✅ avifenc installed successfully!")
print(f"📁 Installation path: {avifenc_path}")
print(f"🔧 Please ensure {scripts_dir} is in PATH")
zip_dst = os.path.join(scripts_dir, "avifenc.zip")
if os.path.exists(zip_dst):
os.remove(zip_dst)
print(f"✅ 删除临时文件: {zip_dst}")
print(f"✅ Deleted temporary file: {zip_dst}")
return True
else:
print(f"❌ avifenc未找到在 {avifenc_dir}")
print(f"❌ avifenc not found in {avifenc_dir}")
return False
except Exception as e:
print(f"❌ 安装失败: {str(e)}")
print(f"❌ Installation failed: {str(e)}")
import traceback
traceback.print_exc()
return False