Mehedi258456 commited on
Commit
ff71f47
·
verified ·
1 Parent(s): a383fa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from PIL import Image
3
- import io
4
 
5
  def upscale(image, scale):
6
  width, height = image.size
@@ -8,11 +8,10 @@ def upscale(image, scale):
8
  new_height = int(height * scale)
9
  upscaled = image.resize((new_width, new_height), Image.BICUBIC)
10
 
11
- # Save as JPG in memory
12
- buffer = io.BytesIO()
13
- upscaled.convert("RGB").save(buffer, format="JPEG", quality=95)
14
- buffer.seek(0)
15
- return buffer
16
 
17
  title = "Simple Image Upscaler (JPG Download)"
18
  description = "Upload an image and choose scale (2x, 4x, 8x). The image will be resized and downloaded as JPG."
 
1
  import gradio as gr
2
  from PIL import Image
3
+ import tempfile
4
 
5
  def upscale(image, scale):
6
  width, height = image.size
 
8
  new_height = int(height * scale)
9
  upscaled = image.resize((new_width, new_height), Image.BICUBIC)
10
 
11
+ # Save to a temp JPG file
12
+ temp_file = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
13
+ upscaled.convert("RGB").save(temp_file.name, format="JPEG", quality=95)
14
+ return temp_file.name
 
15
 
16
  title = "Simple Image Upscaler (JPG Download)"
17
  description = "Upload an image and choose scale (2x, 4x, 8x). The image will be resized and downloaded as JPG."