h51 python库为h51 api提供了pythonic接口。
H51的Python项目详细描述
h51 python库
h51 python库为h51 api提供了pythonic接口。它包括一个api客户机类、一组资源类以及用于配置核心分析器和转换的类。
安装
pip install h51
要求
- Python3.7+
用法
importh51client=h51.Client('your_api_key...')# Create an assetwithopen('image.bmp')asf:asset=h51.resources.Asset.create(client,f)# Analyze the image asset to find its dominant colours and focal pointasset.analyze([h51.transforms.images.DominantColours(),h51.analyzers.images.FocalPoint()])# Create web optimized variations of the imageh51.resources.Variation.create(asset,{'x1':[h51.transforms.images.AutoOrient(),h51.transforms.images.FocalPointCrop(aspect_ratio=0.5),h51.transforms.images.Fit(640,640),h51.transforms.images.Output('WEBP')],'x2':[h51.transforms.images.AutoOrient(),h51.transforms.images.FocalPointCrop(aspect_ratio=0.5),h51.transforms.images.Fit(1280,1280),h51.transforms.images.Output('WEBP')]}])