soiz1 commited on
Commit
888cd71
·
verified ·
1 Parent(s): 99ee49c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -33,7 +33,13 @@ def downscale_pdf(pdf_file, max_width=3000, dpi=150):
33
  with open(output_pdf_path, "wb") as f:
34
  f.write(img2pdf.convert(downscaled_images))
35
 
36
- return output_pdf_path
 
 
 
 
 
 
37
 
38
  with gr.Blocks() as demo:
39
  gr.Markdown("## PDFダウンサイザー for Audiveris")
 
33
  with open(output_pdf_path, "wb") as f:
34
  f.write(img2pdf.convert(downscaled_images))
35
 
36
+ # ✅ Gradio返却用に一時ファイルにコピー
37
+ final_pdf_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
38
+ with open(output_pdf_path, "rb") as src, open(final_pdf_file.name, "wb") as dst:
39
+ dst.write(src.read())
40
+
41
+ return final_pdf_file.name
42
+
43
 
44
  with gr.Blocks() as demo:
45
  gr.Markdown("## PDFダウンサイザー for Audiveris")