{"id":14110296,"url":"https://github.com/siiptuo/pio","last_synced_at":"2026-01-17T08:15:42.180Z","repository":{"id":48347857,"uuid":"202369618","full_name":"siiptuo/pio","owner":"siiptuo","description":"Optimize images while maintaining the same perceived quality","archived":false,"fork":false,"pushed_at":"2023-07-10T17:40:39.000Z","size":3094,"stargazers_count":140,"open_issues_count":10,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-14T10:15:54.729Z","etag":null,"topics":["image-optimization","web-performance"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siiptuo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSES/AGPL-3.0-or-later.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-08-14T14:42:19.000Z","updated_at":"2024-08-07T18:09:58.000Z","dependencies_parsed_at":"2024-01-08T07:57:49.981Z","dependency_job_id":"dc574573-e514-400d-8005-cfbc9df813bd","html_url":"https://github.com/siiptuo/pio","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siiptuo%2Fpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siiptuo%2Fpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siiptuo%2Fpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siiptuo%2Fpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siiptuo","download_url":"https://codeload.github.com/siiptuo/pio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228369104,"owners_count":17909191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-optimization","web-performance"],"created_at":"2024-08-14T10:02:46.427Z","updated_at":"2026-01-17T08:15:42.158Z","avatar_url":"https://github.com/siiptuo.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2019-2020 Tuomas Siipola\nSPDX-FileCopyrightText: 2020 Johannes Siipola\n\nSPDX-License-Identifier: AGPL-3.0-or-later\n--\u003e\n\n# Perceptual Image Optimizer \u003cimg src=\"images/pio.gif\" alt=\"\" align=\"right\"\u003e\n\n![Rust](https://github.com/siiptuo/pio/workflows/Rust/badge.svg)\n[![reuse compliant](https://reuse.software/badge/reuse-compliant.svg)](https://reuse.software)\n\n`pio` is a command-line utility to compress image files while maintaining the same perceived quality.\nIt's designed primarily to optimize photographs for the web.\n\n## Features\n\n- Optimize images automatically for the web\n- Supports PNG, JPEG and WebP\n- Ensure images are displayed consistently across browsers by handling ICC profiles and Exif orientation\n- Powered by great projects like [mozjpeg](https://github.com/mozilla/mozjpeg) and [pngquant](https://pngquant.org/)\n- Easily installable statically-linked binary (for Linux and macOS)\n\n`pio` is still under development but should be usable for most images.\nYou can help by testing `pio` and giving feedback by [GitHub issues](https://github.com/siiptuo/pio/issues).\n\n## Background\n\nImages are an important part of the web and make up a large part of the typical website (see HTTP Archive's [Page Weight](https://httparchive.org/reports/page-weight) for statistics).\nOptimizing images can make websites faster to load and reduce the required bandwidth.\n\nHow much should you optimize images?\nMany image editors and optimization tools only give you parameters such as quality or file size.\nYou could use the same parameters for each image.\nThis will certainly optimize your images but may not be optimal for all images.\nYou could also specify parameters by hand for each image but this isn't feasible if there are many images, or if images are uploaded by end users.\n\n`pio` simplifies image optimization by finding optimal parameters automatically.\nThis is done by optimizing the input image with different qualities and comparing [structural similarity (SSIM)](https://en.wikipedia.org/wiki/Structural_similarity).\n\n### Example\n\nHere we can see that `pio` finds different quality parameter for different images (using default settings).\nIn general images with a lot of details require higher quality than those with fewer details.\n\nHowever, `pio` is not perfect: for example some JPEG artifacts are visible in the first example image.\nIn this case the quality setting is optimized for the solid sky covering most of the image but not the finer details of the bridge.\n\n| Original                                                                                                                                                                                                                                                                          | Optimized JPEG                                                           | Optimized WebP                                                           |\n| -                                                                                                                                                                                                                                                                                 | -                                                                        | -                                                                        |\n| ![](images/image1-original.png)\u003cbr\u003ePhoto: [Josh Felise](https://www.snapwi.re/user/JPFelise)\u003cbr\u003e[CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) \u0026bullet; [Source](https://snapwiresnaps.tumblr.com/post/140752672614/josh-felise-free-under-cc0-10-download)        | ![](images/image1-jpeg.png)\u003cbr\u003e**File size:** 2.1 KiB\u003cbr\u003e**Quality:** 75 | ![](images/image1-webp.png)\u003cbr\u003e**File size:** 2.0 KiB\u003cbr\u003e**Quality:** 83 |\n| ![](images/image2-original.png)\u003cbr\u003ePhoto: [Dominik Martin](https://www.snapwi.re/user/dominikmartn)\u003cbr\u003e[CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) \u0026bullet; [Source](https://snapwiresnaps.tumblr.com/post/102447448703/dominik-martin-wwwdominikmartin-free)   | ![](images/image2-jpeg.png)\u003cbr\u003e**File size:** 5.5 KiB\u003cbr\u003e**Quality:** 88 | ![](images/image2-webp.png)\u003cbr\u003e**File size:** 5.7 KiB\u003cbr\u003e**Quality:** 89 |\n| ![](images/image3-original.png)\u003cbr\u003ePhoto: [Michael Day](https://www.snapwi.re/user/bucktownchicago)\u003cbr\u003e[CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) \u0026bullet; [Source](https://snapwiresnaps.tumblr.com/post/171101090646/michael-day-free-under-cc0-10-download) | ![](images/image3-jpeg.png)\u003cbr\u003e**File size:** 21 KiB\u003cbr\u003e**Quality:** 95  | ![](images/image3-webp.png)\u003cbr\u003e**File size:** 15 KiB\u003cbr\u003e**Quality:** 81  |\n\n## Installation\n\n### Linux\n\nDownload the latest Linux binary from [GitHub releases](https://github.com/siiptuo/pio/releases).\n\nThere are two versions: glibc and musl.\nglibc version is about 50% faster than musl version but may not work on old and non-glibc-based distributions.\nFor reference, the glibc version is built on Ubuntu 20.04 against glibc 2.31.\n\nAfter downloading the binary, run `chmod +x path-to-pio` to make it executable.\nConsider storing the binary somewhere on your `PATH` like `/usr/local/bin/pio`.\n\n### macOS\n\nDownload the latest macOS binary from [GitHub releases](https://github.com/siiptuo/pio/releases).\n\nAfter downloading the file, run `chmod +x path-to-pio` in your terminal to make it executable.\nNow try running `./path-to-pio --version`.\n\nIf you get an error like \"pio cannot be opened because the developer cannot be verified\", open \"System Preferences\" section \"Security \u0026 Privacy\" tab \"General\" and click \"Allow Anyway\".\nNow you should be able to run `pio`.\nFor more information, see [Safely open apps on your Mac](https://support.apple.com/en-us/HT202491) by Apple.\n\n### Building from source\n\nDownload source code from [GitHub releases](https://github.com/siiptuo/pio/releases) or clone this repository for development version.\nCompiling `pio` requires Rust and C toolchains.\nRun `cargo build --release` to build binary at `target/release/pio`.\n\n## Usage\n\nBasic usage:\n\n```sh\npio input.jpeg --output output.jpeg\n```\n\nThe target quality can be set using `--quality` option:\n\n```sh\npio input.jpeg --quality 95 --output output.jpeg\n```\n\nThe target quality is a value between 0 and 100 and roughly corresponds to JPEG quality values.\n\nFor the full list of available options, run `pio --help`.\n\n### Input images\n\n`pio` works by comparing the optimized image to the input image.\nThe input image should preferably be PNG or lossless WebP, or alternatively JPEG or lossy WebP stored with a high quality setting (95-100).\n`pio` will make already lossy compressed images look worse.\n\nFor the web, the first and most important optimization is resizing images close to the size they're displayed at.\nFor the best result, first resize a high-resolution source image and store the resulting image with lossless compression.\nOnly after this, optimize the resized image with `pio`.\n\nFor example with the help of [ImageMagick](https://imagemagick.org/index.php) you could resize and optimize an image:\n\n```sh\nmagick big.jpeg -resize 640x small.png\npio small.png --output optimized.jpeg\n```\n\nMost likely you also want to use [responsive images](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images) where you create multiple differently sized images for different display resolutions.\nYou should do the resizing and optimization for each size independently.\n\n### Quality setting explained\n\n`pio` uses an internal table to map target `--quality` setting to SSIM value.\nThis table has been calculated by running a corpus of images through JPEG encoder and calculating the average SSIM value for each JPEG quality setting.\n\nThis makes it possible to target the quality using a familiar 0-100 scale instead of a more obscure SSIM value.\n\n`pio` sets the minimum and maximum quality automatically based on the `--quality` option.\nYou can control the quality spread from the target using the `--spread` option. For example the following command:\n\n```sh\npio input.jpeg --quality 80 --spread 10 --output output.jpeg\n```\n\nwill target JPEG quality of 80 with the minimum quality of 70 and maximum quality of 90.\nThe final quality setting will be selected by the SSIM calculation and it will depend on the complexity of the image.\n\nIf you need, you can override this automatic calculation by specifying `--min` and/or `--max` values manually.\n\n## Links\n\n### Integrations\n\n`pio` provides just a command-line interface but there exists integrations for the following systems\n\n- [pio-loader](https://github.com/siiptuo/pio-loader): webpack integration\n\n### Alternatives\n\n`pio` is not really doing anything new and there are many similar projects including\n\n- [Guetzli](https://github.com/google/guetzli/)\n- [Imager](https://github.com/imager-io/imager)\n- [imgmin](https://github.com/rflynn/imgmin)\n- [optimal-image](https://github.com/optimal-image/optimal-image)\n- [webp-recompress](https://github.com/AgentCosmic/webp-recompress)\n- `jpeg-recompress` from [JPEG Archive](https://github.com/danielgtaylor/jpeg-archive/)\n\n### Reading\n\n- Essential Image Optimization ([mirror](https://joppuyo.github.io/images-guide-mirror/), [wayback machine](https://web.archive.org/web/20200424075529/https://images.guide/)) is a good introduction to different image formats and optimization techniques\n- [Is WebP really better than JPEG?](https://siipo.la/blog/is-webp-really-better-than-jpeg) compares different images formats at the same SSIM index\n\n## License\n\nLicense information is provided according to the [REUSE specification](https://reuse.software/spec/).\nIn summary:\n\n- `pio` source code is available under AGPL-3.0-or-later.\n- Other files are licensed under various Creative Commons licenses.\n\nFor more accurate information, check the individual files and [`.reuse/dep5`](.reuse/dep5).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiiptuo%2Fpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiiptuo%2Fpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiiptuo%2Fpio/lists"}