iasjkk commited on
Commit
fbd31cc
·
verified ·
1 Parent(s): fa8f4e5

Update RGBA2RGB_conversion.py

Browse files
Files changed (1) hide show
  1. RGBA2RGB_conversion.py +14 -1
RGBA2RGB_conversion.py CHANGED
@@ -9,4 +9,17 @@ def convert_png_with_alpha_to_png(png_path, output_png_path, background_color=(2
9
  background.paste(png, mask=png.split()[3])
10
  else:
11
  background.paste(png)
12
- background.save(output_png_path, 'PNG')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  background.paste(png, mask=png.split()[3])
10
  else:
11
  background.paste(png)
12
+ background.save(output_png_path, 'PNG')
13
+
14
+
15
+
16
+
17
+ from PIL import Image
18
+
19
+ png = Image.open(object.logo.path)
20
+ png.load() # required for png.split()
21
+
22
+ background = Image.new("RGB", png.size, (255, 255, 255))
23
+ background.paste(png, mask=png.split()[3]) # 3 is the alpha channel
24
+
25
+ background.save('foo.jpg', 'JPEG', quality=80)