radames commited on
Commit
2103726
1 Parent(s): 2783b0d

switch to webp format

Browse files
frontend/src/lib/App.svelte CHANGED
@@ -95,7 +95,7 @@
95
  status: Status.loading
96
  });
97
  const sessionHash = crypto.randomUUID();
98
- const base64Crop = $maskEl.toDataURL('image/png');
99
 
100
  const hashpayload = {
101
  fn_index: 0,
 
95
  status: Status.loading
96
  });
97
  const sessionHash = crypto.randomUUID();
98
+ const base64Crop = $maskEl.toDataURL('image/webp');
99
 
100
  const hashpayload = {
101
  fn_index: 0,
frontend/src/lib/PaintCanvas.svelte CHANGED
@@ -69,7 +69,7 @@
69
  }
70
  })
71
  .map((e) => {
72
- const split_str = e.imgURL.split(/-|.jpg/);
73
  const date = parseInt(split_str[0]);
74
  const id = split_str[1];
75
  const [x, y] = split_str[2].split('_');
 
69
  }
70
  })
71
  .map((e) => {
72
+ const split_str = e.imgURL.split(/-|.jpg|.webp/);
73
  const date = parseInt(split_str[0]);
74
  const id = split_str[1];
75
  const [x, y] = split_str[2].split('_');
stablediffusion-infinity/app.py CHANGED
@@ -39,6 +39,7 @@ HF_TOKEN = os.environ.get("API_TOKEN") or True
39
  FILE_TYPES = {
40
  'image/png': 'png',
41
  'image/jpeg': 'jpg',
 
42
  }
43
  S3_DATA_FOLDER = Path("sd-multiplayer-data")
44
  ROOMS_DATA_DB = S3_DATA_FOLDER / "rooms_data.db"
@@ -366,14 +367,14 @@ async def upload_file(image: Image.Image, prompt: str, room_id: str, image_key:
366
  image = image.convert('RGB')
367
  # print("Uploading file from predict")
368
  temp_file = io.BytesIO()
369
- image.save(temp_file, format="JPEG")
370
  temp_file.seek(0)
371
  id = shortuuid.uuid()
372
  date = int(time.time())
373
  prompt_slug = slugify(prompt)
374
- filename = f"{date}-{id}-{image_key}-{prompt_slug}.jpg"
375
  s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
376
- filename, ExtraArgs={"ContentType": "image/jpeg", "CacheControl": "max-age=31536000"})
377
  temp_file.close()
378
 
379
  out = {"url": f'https://d26smi9133w0oo.cloudfront.net/{room_id}/{filename}',
 
39
  FILE_TYPES = {
40
  'image/png': 'png',
41
  'image/jpeg': 'jpg',
42
+ 'imager/webp': 'webp',
43
  }
44
  S3_DATA_FOLDER = Path("sd-multiplayer-data")
45
  ROOMS_DATA_DB = S3_DATA_FOLDER / "rooms_data.db"
 
367
  image = image.convert('RGB')
368
  # print("Uploading file from predict")
369
  temp_file = io.BytesIO()
370
+ image.save(temp_file, format="WEBP")
371
  temp_file.seek(0)
372
  id = shortuuid.uuid()
373
  date = int(time.time())
374
  prompt_slug = slugify(prompt)
375
+ filename = f"{date}-{id}-{image_key}-{prompt_slug}.webp"
376
  s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=f"{room_id}/" +
377
+ filename, ExtraArgs={"ContentType": "image/webp", "CacheControl": "max-age=31536000"})
378
  temp_file.close()
379
 
380
  out = {"url": f'https://d26smi9133w0oo.cloudfront.net/{room_id}/{filename}',