def attach_image(img_dict, filename):
 img_path = img_dict['path']
 if (not img_path.startswith('/')):
  img_path = file_path_finder(img_path)
 if img_path:
  with open(img_path, 'rb') as img:
   msg_image = MIMEImage(img.read(), name=os.path.basename(img_path))
   msg_image.add_header('Content-ID', '<{}>'.format(img_dict['cid']))
   msg_image.add_header('Content-Disposition', 'inline', filename=filename)
  return msg_image

def attach_image ( img_dict , filename ) : img_path = img_dict [ 'path' ] if ( not img_path . startswith ( '/' ) ) : img_path = file_path_finder ( img_path ) if img_path : with open ( img_path , 'rb' ) as img : msg_image = MIMEImage ( img . read ( ) , name = os . path . basename ( img_path ) ) msg_image . add_header ( 'Content-ID' , '<{}>' . format ( img_dict [ 'cid' ] ) ) msg_image . add_header ( 'Content-Disposition' , 'inline' , filename = filename ) return msg_image
attach images in the email headers .