barunsaha commited on
Commit
f64ef46
·
1 Parent(s): 900516a

Set transparency of the background images to 50%

Browse files
Files changed (1) hide show
  1. helpers/pptx_helper.py +15 -0
helpers/pptx_helper.py CHANGED
@@ -213,6 +213,10 @@ def generate_powerpoint_presentation(
213
 
214
  except Exception:
215
  # In case of any unforeseen error, try to salvage what is available
 
 
 
 
216
  continue
217
 
218
  # The thank-you slide
@@ -486,6 +490,17 @@ def _handle_display_image__in_background(
486
  width=pptx.util.Inches(slide_width_inch),
487
  )
488
 
 
 
 
 
 
 
 
 
 
 
 
489
  _add_text_at_bottom(
490
  slide=slide,
491
  slide_width_inch=slide_width_inch,
 
213
 
214
  except Exception:
215
  # In case of any unforeseen error, try to salvage what is available
216
+ logger.error(
217
+ 'An error occurred while processing a slide...continuing with the next one',
218
+ exc_info=True
219
+ )
220
  continue
221
 
222
  # The thank-you slide
 
490
  width=pptx.util.Inches(slide_width_inch),
491
  )
492
 
493
+ # Print the XML for debugging
494
+ blip = picture._element.xpath('.//a:blip')[0]
495
+ # Add transparency to the image through the blip properties
496
+ alpha_mod = blip.makeelement(
497
+ '{http://schemas.openxmlformats.org/drawingml/2006/main}alphaModFix'
498
+ )
499
+ alpha_mod.set('amt', '50000') # 50% opacity
500
+ blip.append(alpha_mod)
501
+ logger.debug('Blip element after: %s', blip.xml)
502
+ picture._element.xpath('.//a:blip')[0].append(alpha_mod)
503
+
504
  _add_text_at_bottom(
505
  slide=slide,
506
  slide_width_inch=slide_width_inch,