Skip to content

脚本里每次压缩图片调用了两次压缩接口方法 #2

@xrksudy

Description

@xrksudy

参考tinypng官方接口文档:https://tinypng.com/developers/reference/python
可以发现脚本中压缩统一张图片调用了2次接口,由于每个key每个月只能免费压缩500张,因此这种方式每压缩一张图片就浪费了一次机会。

方式一

source = tinify.from_file(root + '/' + name)
source.to_file(toFullName)

方式二

with open(toFullName, 'rb') as source:
source_data = source.read()
result_data = tinify.from_buffer(source_data).to_buffer()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions