cormort commited on
Commit
86a12d4
·
verified ·
1 Parent(s): 4612a63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -16
app.py CHANGED
@@ -1,5 +1,3 @@
1
- # --- 超穩定版本 app.py ---
2
-
3
  import gradio as gr
4
  import subprocess
5
  import os
@@ -104,28 +102,17 @@ def convert_pdf_to_cmyk_simple(input_path):
104
  output_file = f"/tmp/{base_name}_cmyk_simple.pdf"
105
 
106
  # 最簡化的命令
107
- # 檢查設定檔是否存在
108
- settings_file = "cmyk_settings.ps"
109
- if not os.path.exists(settings_file):
110
- return None, "❌ 找不到色彩設定檔 cmyk_settings.ps"
111
-
112
  command = [
113
  gs_path,
114
  "-dSAFER",
115
  "-dBATCH",
116
  "-dNOPAUSE",
117
  "-sDEVICE=pdfwrite",
118
- # -I. 參數告訴 Ghostscript 在目前目錄尋找 .icc 檔案
119
- "-I.",
120
  f"-sOutputFile={output_file}",
121
- # 在輸入 PDF 之前載入我們的顏色設定
122
- settings_file,
123
  input_path
124
  ]
125
 
126
- # 因為所有設定都在 .ps 檔裡了,所以 profile_name 可以直接寫
127
- profile_name = "Japan Color 2011 Coated"
128
-
129
  try:
130
  subprocess.run(command, check=True, capture_output=True, timeout=120)
131
  if os.path.exists(output_file) and os.path.getsize(output_file) > 0:
@@ -242,9 +229,7 @@ def process_pdf(input_file, progress=gr.Progress()):
242
 
243
  if output_path:
244
  conversion_message = f"""🔄 已使用簡化模式轉換
245
-
246
  {simple_message}
247
-
248
  ℹ️ 原因:進階參數不相容
249
  ✅ 結果:CMYK 轉換完成
250
  ⚠️ 備註:簡化模式使用基本色彩轉換,適用於大多數印刷需求
 
 
 
1
  import gradio as gr
2
  import subprocess
3
  import os
 
102
  output_file = f"/tmp/{base_name}_cmyk_simple.pdf"
103
 
104
  # 最簡化的命令
 
 
 
 
 
105
  command = [
106
  gs_path,
107
  "-dSAFER",
108
  "-dBATCH",
109
  "-dNOPAUSE",
110
  "-sDEVICE=pdfwrite",
111
+ "-sColorConversionStrategy=CMYK",
 
112
  f"-sOutputFile={output_file}",
 
 
113
  input_path
114
  ]
115
 
 
 
 
116
  try:
117
  subprocess.run(command, check=True, capture_output=True, timeout=120)
118
  if os.path.exists(output_file) and os.path.getsize(output_file) > 0:
 
229
 
230
  if output_path:
231
  conversion_message = f"""🔄 已使用簡化模式轉換
 
232
  {simple_message}
 
233
  ℹ️ 原因:進階參數不相容
234
  ✅ 結果:CMYK 轉換完成
235
  ⚠️ 備註:簡化模式使用基本色彩轉換,適用於大多數印刷需求