pekingzcc

开源一个压缩 Cloudfare R2 图片的工具

  •  
  •   pekingzcc · Apr 29, 2025 · 1510 views
    This topic created in 422 days ago, the information mentioned may be changed or developed.

    起因是自己的一个生图项目把图片放到了 CLoudfare R2 上,不过上传之前没有做好压缩优化,导致有很多存量的图片很大,就做了这一个小工具将 cloudfare r2 上的图片批量压缩并上传覆盖,最后有一个压缩的 report 。

    地址: https://github.com/zhangchenchen/reduce_cloudfare_image

    效果大致如下:

    Output Example

    Files to be processed:
    +--------------------------------------------------------------+------+----------+----------+
    | File Path                                                     | Format| Size(KB) | Size(MB) |
    +==============================================================+======+==========+==========+
    | themes/steampunk-game-community/steampunk-game-community.png | PNG  | 664.5 KB | 0.65 MB  |
    +--------------------------------------------------------------+------+----------+----------+
    | Total                                                        | 1 file| 664.5 KB | 0.65 MB  |
    +--------------------------------------------------------------+------+----------+----------+
    
    Processing 1 file, total size 0.65 MB. Continue? (y/n): y
    
    Processing images: 100%|████████████████████████████████████| 1/1 [00:06<00:00,  6.36s/it]
    
    Image Compression Report:
    +--------------------------------------------------------------+----------+----------+----------+-------+--------+
    | File                                                          | Original | Compressed| Space    | Ratio | Time   |
    |                                                              | Size     | Size      | Saved    |       |        |
    +==============================================================+==========+==========+==========+=======+========+
    | themes/steampunk-game-community/steampunk-game-community.png | 664.5 KB | 529.1 KB | 135.3 KB | 20.4% | 2.7s   |
    +--------------------------------------------------------------+----------+----------+----------+-------+--------+
    | Total                                                         | 664.5 KB | 529.1 KB | 135.3 KB | 20.4% | -      |
    +--------------------------------------------------------------+----------+----------+----------+-------+--------+
    | Total(MB)                                                     | 0.65 MB  | 0.52 MB  | 0.13 MB  | 20.4% | -      |
    +--------------------------------------------------------------+----------+----------+----------+-------+--------+
    
    Processed 1 file
    Total space saved: 0.13 MB
    Average compression ratio: 20.4%
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3689 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 04:22 · PVG 12:22 · LAX 21:22 · JFK 00:22
    ♥ Do have faith in what you're doing.