def embed_item(item, imagepath, maxwidth=None, itempath=None, compare_threshold=0, ifempty=False, as_album=False):
 if compare_threshold:
  if (not check_art_similarity(item, imagepath, compare_threshold)):
   log.warn(u'Image not similar; skipping.')
   return
 if ifempty:
  art = get_art(item)
  if (not art):
   pass
  else:
   log.debug(u'embedart: media file contained art already {0}'.format(displayable_path(imagepath)))
   return
 if (maxwidth and (not as_album)):
  imagepath = resize_image(imagepath, maxwidth)
 try:
  log.debug(u'embedart: embedding {0}'.format(displayable_path(imagepath)))
  item['images'] = [_mediafile_image(imagepath, maxwidth)]
 except IOError as exc:
  log.error(u'embedart: could not read image file: {0}'.format(exc))
 else:
  item.try_write(itempath)
  del item['images']

def embed_item ( item , imagepath , maxwidth = None , itempath = None , compare_threshold = 0 , ifempty = False , as_album = False ) : if compare_threshold : if ( not check_art_similarity ( item , imagepath , compare_threshold ) ) : log . warn ( u'Image not similar; skipping.' ) return if ifempty : art = get_art ( item ) if ( not art ) : pass else : log . debug ( u'embedart: media file contained art already {0}' . format ( displayable_path ( imagepath ) ) ) return if ( maxwidth and ( not as_album ) ) : imagepath = resize_image ( imagepath , maxwidth ) try : log . debug ( u'embedart: embedding {0}' . format ( displayable_path ( imagepath ) ) ) item [ 'images' ] = [ _mediafile_image ( imagepath , maxwidth ) ] except IOError as exc : log . error ( u'embedart: could not read image file: {0}' . format ( exc ) ) else : item . try_write ( itempath ) del item [ 'images' ]
embed an image into the items media file .