{"id":15487763,"url":"https://github.com/virtubox/img-optimize","last_synced_at":"2025-08-20T16:32:14.353Z","repository":{"id":43770103,"uuid":"71062509","full_name":"VirtuBox/img-optimize","owner":"VirtuBox","description":"Image optimization bash script","archived":false,"fork":false,"pushed_at":"2023-07-27T13:11:56.000Z","size":3180,"stargazers_count":126,"open_issues_count":7,"forks_count":40,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-19T07:54:38.180Z","etag":null,"topics":["debian","image-compression","image-optimization","jpegoptim","jpg","libwebp","optipng","png","ubuntu","webp","webp-conversion"],"latest_commit_sha":null,"homepage":"https://virtubox.github.io/img-optimize/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VirtuBox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-16T16:27:03.000Z","updated_at":"2024-10-18T07:45:43.000Z","dependencies_parsed_at":"2024-10-31T06:31:36.832Z","dependency_job_id":"0887dc14-5877-4acb-8a5c-99c8a7ccaddf","html_url":"https://github.com/VirtuBox/img-optimize","commit_stats":{"total_commits":77,"total_committers":6,"mean_commits":"12.833333333333334","dds":0.5194805194805194,"last_synced_commit":"c78ff855ef750c64ffe02fd9d3dd42a12db93fbe"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtuBox%2Fimg-optimize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtuBox%2Fimg-optimize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtuBox%2Fimg-optimize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtuBox%2Fimg-optimize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VirtuBox","download_url":"https://codeload.github.com/VirtuBox/img-optimize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438185,"owners_count":18225870,"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":["debian","image-compression","image-optimization","jpegoptim","jpg","libwebp","optipng","png","ubuntu","webp","webp-conversion"],"created_at":"2024-10-02T06:41:40.083Z","updated_at":"2024-12-19T13:07:59.761Z","avatar_url":"https://github.com/VirtuBox.png","language":"Shell","readme":"# Image optimization bash script\n\n![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)\n\n[![Travis](https://travis-ci.org/VirtuBox/img-optimize.svg?branch=master)](https://travis-ci.org/VirtuBox/img-optimize) ![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)\n\n## Prerequisite\n\n- jpegoptim for jpg optimization\n- optipng for png optimization\n- cwebp for WebP conversion\n- go-avif for Avif conversion\n\n### From APT repositories\n\nDebian/Ubuntu :\n\n```bash\nsudo apt install jpegoptim optipng webp -y\n```\n\nCentos 7 :\n\n```bash\nsudo yum install optipng jpegoptim libwebp-tools -y\n```\n\n### Compile the latest release (optipng \u0026 libwebp)\n\nFor Debian/Ubuntu (available in scripts folder) :\n\n```bash\n# optipng\ncurl -sL git.io/fjddn | sudo -E bash\n\n# libwebp\ncurl -sL git.io/fjdd6 | sudo -E bash\n```\n\n### Go-Avif installation\n\n```bash\nsudo wget -qO /usr/local/bin/avif https://github.com/Kagami/go-avif/releases/download/v0.1.0/avif-linux-x64\nsudo chmod +x /usr/local/bin/avif\n```\n\n--------------------------------------------------------------------------------\n\n## Installation\n\n1) Clone the repository\n\n```bash\ngit clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize\n```\n\n2) Install the script\n\n**Method 1** : Add an alias in .bashrc\n\nWith this method img-optimize can only be used by the current user\n\n```bash\necho \"alias img-optimize=$HOME/.img-optimize/optimize.sh\" \u003e\u003e $HOME/.bashrc\nsource $HOME/.bashrc\n```\n\n**Method 2** : Add an alias to the script in /usr/local/bin\n\nWith this method img-optimize can be used by all users\n\n```bash\nsudo ln -s $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize\nsudo chmod +x /usr/local/bin/img-optimize\n```\n\n## Usage\n\n```bash\nBash script to optimize your images and convert them in WebP\nUsage: img-optimize [options] \u003cimages path\u003e\nIf images path isn't defined, img-optimize will use the current directory\n  Options:\n       --jpg ..... optimize all jpg images\n       --png ..... optimize all png images\n       --webp ..... convert all images in webp\n       --avif ..... convert all images in avif\n       --std ..... optimize all png \u0026 jpg images\n       --next ..... convert all images in webp \u0026 avif\n       --all ..... optimize all images (png + jpg + webp + avif)\n       -i, --interactive ..... run img-optimize in interactive mode\n       -q, --quiet ..... run image optimization quietly\n       --path \u003cimages path\u003e ..... define images path\n Other options :\n       -h, --help, help ... displays this help information\n       --cmin [+|-]\u003cn\u003e ... File's status was last changed n minutes ago.\n         act find cmin argument (+n : greater than n, -n : less than n, n : exactly n)\nExamples:\n  optimize all jpg images in /var/www/images\n    img-optimize --jpg --path /var/www/images\n```\n\n### Update the script\n\nTo update the script, just run :\n\n```bash\ngit -C $HOME/.img-optimize pull\n```\n\n### Setup daily cronjob\n\nYou just have to copy the scripts to /etc/cron.daily :\n\n```bash\ncp $HOME/.img-optimize/crons/jpg-png-cron.sh /etc/cron.daily/jpg-png-cron\ncp $HOME/.img-optimize/crons/jpg-png-cron.sh /etc/cron.daily/webp-cron\n\nchmod +x /etc/cron.daily/jpg-png-cron\nchmod +x /etc/cron.daily/webp-cron\n```\n\nThen just edit your websites path set with the variables `sites` at the beginning of the cron scripts.\n\n## Warning\n\nConversion process can take a while, you can use `tmux` to launch the script and be able to close your ssh connection without interrupting conversion. Then just use `tmux attach` to login back in your tmux session.\n\n## Credits\n\n- WebP conversion script was inspired by this [DigitalOcean Community Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website)\n\n- Tutorial about webp conversion available on [jesuisadmin.fr](https://jesuisadmin.fr/convertir-vos-images-en-webp-nginx/) (in french)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtubox%2Fimg-optimize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtubox%2Fimg-optimize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtubox%2Fimg-optimize/lists"}