Skip to main content

Fast image compression for large number of images with Ray library

Project description

Ray-Image

🚀 Fast image compression for large number of images with Ray library.

Supported Python versions PEP8 Poetry-build

Requirements

To install ray, run:

pip install ray

⬇️ Installation

pip install rayim

⌨️ Usage

usage: rayim [-h] [-o OUTPUT_DIR] [-q QUALITY] [--overwrite] [-n] [-j]
             [--replicate-dir-tree] [-s SIZE SIZE] [-d DIV_BY] [-S] [-O]
             path [path ...]

positional arguments:
  path                  Path to a single file/directory or multiple
                        files/directories

options:
  -h, --help            show this help message and exit
  -o OUTPUT_DIR, --output-dir OUTPUT_DIR
                        Output directory (default: next to original file)
  -q QUALITY, --quality QUALITY
                        Output image quality (JPEG only; default: 70)
  --overwrite           Overwrite the original image
  -n, --no-subsampling  Turn off subsampling and retain the original image
                        setting (JPEG only)
  -j, --to-jpeg         Convert the image(s) to .JPEG
  --replicate-dir-tree  Replicate the source directory tree in the output
  -s SIZE SIZE, --size SIZE SIZE
                        Resize the image to WIDTH HEIGHT
  -d DIV_BY, --div-by DIV_BY
                        Divide the image size (WxH) by a factor of n
  -S, --silent          Silent mode
  -O, --optimize        Apply default optimization on the image(s)
  -k, --keep-date       Keep the original modification date

📕 Examples

  • Running on a single file:
rayim foo.jpg
# 🚀 foo.jpg: 1157. kB ==> 619.9 kB (-46.4%) | 0.07s
  • Running on a folder foo and writing the output to compressed
rayim foo/ -o compressed
# (compress_many pid=612778) 🚀 foo.jpg: 988.9 kB ==> 544.8 kB (-44.9%) | 0.08s
# (compress_many pid=612828) 🚀 bar.jpg: 983.8 kB ==> 541.2 kB (-44.9%) | 0.07s
# (compress_many pid=612826) 🚀 foobar.jpg: 1001. kB ==> 550.7 kB (-44.9%) | 0.07s
# (compress_many pid=612786) 🚀 barfoo.jpg: 1001. kB ==> 551.9 kB (-44.8%) | 0.08s
# ...

# Total:
#    Before: 1091.32 MB
#    After: 599.46 MB (-45.0%)

Speed comparison

Test 1 (on Apple Silicon M1, 8-cores)

Method Number of files Speed
Regular compression 1,000 60.090s
rayim 1,000 26.937s (55.17% faster)
Total:
    Before: 1091.32 MB
    After: 599.46 MB (-45.0%)

Test 2 (on Intel @ 2.299GHz, 32-cores)

Method Number of files Speed
Regular compression 6,000 7m42.919s
rayim 6,000 5m15.423s (31.96% faster)
Total:
    Before: 6040.59 MB
    After: 3321.70 MB (-45.0%)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rayim-1.9.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rayim-1.9.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file rayim-1.9.0.tar.gz.

File metadata

  • Download URL: rayim-1.9.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.8 Darwin/25.5.0

File hashes

Hashes for rayim-1.9.0.tar.gz
Algorithm Hash digest
SHA256 d81c38eaf498d3e4615e409e707a254c458d456d09d189918a147eee39eee207
MD5 682f7eeb3f6316b73cee8da9818c3e71
BLAKE2b-256 44d6f97be44ff402c69bc2caa080d598e52a48081daea96ebcbb6e3ea386fecb

See more details on using hashes here.

File details

Details for the file rayim-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: rayim-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.8 Darwin/25.5.0

File hashes

Hashes for rayim-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8d8ad3f3d7f67555a581a3c69860e5d9d9a21441dece7eb69f013c7b880b845
MD5 f071453652204f6b008c897d5fd6c46b
BLAKE2b-256 5237e4048004df5d9ee428a983ba7fa803acbe24d8968114ced0800eef86d669

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page