本文整理汇总了Python中mutagen.flac.Picture.depth方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.depth方法的具体用法?Python Picture.depth怎么用?Python Picture.depth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.flac.Picture
的用法示例。
在下文中一共展示了Picture.depth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_image
# 需要导入模块: from mutagen.flac import Picture [as 别名]
# 或者: from mutagen.flac.Picture import depth [as 别名]
def set_image(self, image):
"""Replaces all embedded images by the passed image"""
with translate_errors():
audio = self.MutagenType(self["~filename"])
try:
data = image.read()
except EnvironmentError as e:
raise AudioFileError(e)
pic = Picture()
pic.data = data
pic.type = APICType.COVER_FRONT
pic.mime = image.mime_type
pic.width = image.width
pic.height = image.height
pic.depth = image.color_depth
audio.pop("coverart", None)
audio.pop("coverartmime", None)
audio["metadata_block_picture"] = base64.b64encode(
pic.write()).decode("ascii")
with translate_errors():
audio.save()
self.has_images = True
示例2: download_and_fix_ogg
# 需要导入模块: from mutagen.flac import Picture [as 别名]
# 或者: from mutagen.flac.Picture import depth [as 别名]
def download_and_fix_ogg(ogg, audio_metadata, cover_art_file):
global DRY_RUN
if DRY_RUN:
print "This is a dry run. So pretending to download the ogg..."
return "/tmp/ogg"
print "Now downloading the ogg in order to set the metadata in it..."
if not LIVE and len(sys.argv) >= 6 and os.path.exists(sys.argv[5]):
ogg_local_fn = sys.argv[5]
print "(using presupplied file %s)" % ogg_local_fn
else:
f, metadata = client.get_file_and_metadata(ogg)
ogg_local_fn = fetch_file(f, metadata)
print "Successfully downloaded (to %s): now editing metadata..." % ogg_local_fn
audio = OggVorbis(ogg_local_fn)
for k in audio_metadata.keys():
audio[k] = audio_metadata[k]
# add cover art
im=Image.open(cover_art_file)
w,h=im.size
p=Picture()
imdata=open(cover_art_file,'rb').read()
p.data=imdata
p.type=3
p.desc=''
p.mime='image/jpeg';
p.width=w; p.height=h
p.depth=24
dt=p.write();
enc=base64.b64encode(dt).decode('ascii');
audio['metadata_block_picture']=[enc];
audio.save()
print "Successfully updated metadata."
return ogg_local_fn
示例3: ogg_coverart
# 需要导入模块: from mutagen.flac import Picture [as 别名]
# 或者: from mutagen.flac.Picture import depth [as 别名]
def ogg_coverart(config):
print("Adding " + config.coverart_mime + " cover art to " + config.ogg_file)
coverart = config.coverart
imgdata = open(coverart,'rb').read()
im = Image.open(coverart)
w,h = im.size
p = Picture()
p.data = imgdata
p.type = 3
p.desc = 'Cover'
p.mime = config.coverart_mime
p.width = w
p.height = h
p.depth = 24
dt=p.write()
enc=base64.b64encode(dt).decode('ascii')
audio = OggVorbis(config.ogg_file)
audio['metadata_block_picture']=[enc]
audio.save()
示例4: set_image
# 需要导入模块: from mutagen.flac import Picture [as 别名]
# 或者: from mutagen.flac.Picture import depth [as 别名]
def set_image(self, image):
"""Replaces all embedded images by the passed image"""
try:
audio = self.MutagenType(self["~filename"])
data = image.file.read()
except EnvironmentError:
return
pic = Picture()
pic.data = data
pic.type = APICType.COVER_FRONT
pic.mime = image.mime_type
pic.width = image.width
pic.height = image.height
pic.depth = image.color_depth
audio.pop("coverart", None)
audio.pop("coverartmime", None)
audio["metadata_block_picture"] = base64.b64encode(pic.write())
audio.save()
self.has_images = True