# picopt
A multi-format, recursive, multiprocessor aware, command line, lossless image
optimizer utility that can use external tools for even better optimizing.
Picopt will optionally drop hidden timestamps at the root of your image
directories to avoid reoptimizing images picopt has already optimized.
## 💭 <a name="philosophy">Conversion Philosophy</a>
### Warning
Picopt transforms images in place and throws out the old image. Always have a
backup of images before running picopt in case you are not satisfied with the
results.
### Lossy Images
Converting lossy images rarely makes sense and so picopt only optimizes them in
their current format.
- JPEG images are optimized with MozJpeg's jpegtran.
- WEBP Lossy images are not optimized. There is no current way to preserve
information without running it through a lossy process again.
### Lossless Images
Lossless WebP images are smaller than PNG, much smaller than GIF and, of course,
a great deal smaller than uncompressed bitmaps like BMP. As such the best
practice is probably to convert all lossless images to WebP Lossless as now all
major browsers support it. The only downside is that decoding WebP Lossless
takes on average 50% more CPU than PNG. All major desktop and mobile browsers
support WEBP. WEBP is the lossless format of choice. Until perhaps JPEG XL
support arrives for browsers.
### Sequenced Images
Sequenced Images, like animated GIFs and WebP, most of the time, should be
converted to a compressed video format like HEVC, VVC, VP9 or VP10. There are
several situations where this is impractical and so Animated WebP is now a good
substitute.
### Conversion
By default, picopt does not convert images between formats. You must turn on
conversion to PNG or WebP explicitly.
## 🖼️ <a name="formats">Formats</a>
- By default picopt will optimize GIF, JPEG, PNG, and WEBP images.
- Picopt can optionally optimize SVG images, ZIP, ePub, and CBZ containers.
- Picopt can convert many lossless images such as BMP, CBR, CUR, DIB, FITS, GIF,
IMT, PCX, PIXAR, PNG, PPM, PSD, QOI, SGI, SPIDER, SUN, TGA, TIFF, XBM, and XPM
into PNG and WEBP.
- Picopt can convert Animated GIF, TIFF, and FLI into Animated PNG or WebP
files.
- Picopt can convert Animated GIF, TIFF, FLI, and PNG into Animated WebP files.
- Picopt can convert MPO to JPEG by stripping secondary images (often thumbnails
created by cameras) if a primary image exists. (Experimental).
- Picopt can convert RAR files into Zipfiles and CBR files into CBZ files.
Because picopt supports so many lossless image formats, to avoid surprises if
you specify a conversion target, picopt will only convert GIF and PNG images to
the target by default. To convert another format, like BMP, to WEBP you must
specify that you want to read the BMP format _and_ that you want to convert it
to WEBP:
<!-- eslint-skip -->
```sh
picopt -x BMP -c WEBP big_old.bmp
```
### JPEG
To optimize JPEG images at all picopt needs one of
[mozjpeg](https://github.com/mozilla/mozjpeg) or
[jpegtran](http://jpegclub.org/jpegtran/) on the path. in order of preference.
### PNG & APNG
Picopt uses an internal oxipng python module to optimize PNG images and convert
other lossless formats to PNG picopt. The external
[pngout](http://advsys.net/ken/utils.htm) tool can provide a small extra bit of
compression.
Animated PNGs are optimized with the internal optimizer.
### Animated GIF
Gifs and Animated GIFs are optimized with
[gifsicle](http://www.lcdf.org/gifsicle/) if available. or interaallly if is
not. Gifsicle only provides a small advantage over the internal optimizer.
### WebP
WebP lossless formats are optimized with
[cwebp](https://developers.google.com/speed/webp/docs/cwebp) if available and
with the internal optimizer if not. cwebp provides significant improvements over
the internal optimizer.
### SVG
Picopt can only optimize SVGs if [svgo](https://github.com/svg/svgo) is on the
path.
### MPO (Experimental)
Picopt can extract the primary image from a multi JPEG MPO that also contains
thumbnails and convert the file to an ordinary JPEG. Picopt will also optimize
this image if it can. To enable this you must run with `-x MPO -c JPEG`
Steroscopic MPOs should have no primary image tagged in the MPO directory and be
unaffected.
This feature has not been tested with a large variety of MPOs and should be
considered experimental.
### EPub
EPub Books are zip files that often contain images and picopt unpacks and
repacks this format natively. Images within the epub are handled by other
programs. EPub optimization is not turned on by default. EPub contents are never
converted to other formats because it would break internal references to them.
### CBZ & CBR
Picopt uncompresses, optimizes and rezips
[comic book archive files](https://en.wikipedia.org/wiki/Comic_book_archive). Be
aware that CBR rar archives may only be rezipped into CBZs instead of CBR. Comic
book archive optimization is not turned on by default to prevent surprises.
## 📦 <a name="install">Install</a>
### System Dependencies
#### Python
Picopt requires Python 3.10 or greater installed on whichever system you use.
Picopt is most effective with these binary dependencies installed. We must
install these first
#### macOS
<!-- eslint-skip -->
```sh
brew install gifsicle mozjpeg svgo webp
ln -s $(brew --prefix)/opt/mozjpeg/bin/jpegtran /usr/local/bin/mozjpeg
```
#### Debian / Ubuntu, Windows Linux Subsystem
<!-- eslint-skip -->
```sh
apt-get install gifsicle python-imaging webp
```
if you don't want to install mozjpeg using the instructions below then use
jpegtran:
<!-- eslint-skip -->
```sh
apt-get install libjpeg-progs
```
See mozjepg, pngout & svgo install instructions below
#### Redhat / Fedora
<!-- eslint-skip -->
```sh
dnf install gifsicle python3-pillow libwebp-tools
```
if you don't want to install mozjpeg using the instructions below then use
jpegtran:
<!-- eslint-skip -->
```sh
dnf install libjpeg-turbo-utils
```
See mozjepg, pngout & svgo install instructions below
### Picopt python package
<!-- eslint-skip -->
```sh
pip install picopt
```
## ⚙️ <a name="programs">External Programs</a>
Picopt will perform optimization on most lossless formats without using external
programs, but much more compression is possible if these external programs are
on your path.
### mozjpeg
mozjpeg offers better compression than libjpeg-progs jpegtran. It may or may not
be packaged for your \*nix, but even when it is, picopt requires that its
separately compiled version of jpegtran be symlinked to 'mozjpeg' somewhere in
the path.
Instructions for installing on macOS are given above. Some near recent binaries
for Windows and Debian x86
[can be found here](https://mozjpeg.codelove.de/binaries.html). Most Linux
distributions still require a more manual installation as elucidated here on
[Casey Hoffer's blog](https://www.caseyhofford.com/2019/05/01/improved-image-compression-install-mozjpeg-on-ubuntu-server/)
### pngout
pngout is a compression tool that can be used for small extra compression. It
does not run on 16 bit PNGs.
It can be installed on macOS with:
<!-- eslint-skip -->
```sh
brew install jonof/kenutils/pngout
```
It is not packaged for linux, but you may find the latest binary version
[on JonoF's site](http://www.jonof.id.au/kenutils). Picopt looks for the binary
to be called `pngout`
### svgo
svgo compresses SVGs. Svgo is packaged for homebrew, but picopt can also use it
if it's installed with npm.
#### On Linux
To install svgo on Linux you can use the snap tool:
<!-- eslint-skip -->
```sh
snap install svgo
```
Or you can install svgo with npm:
<!-- eslint-skip -->
```sh
npm install -G svgo
```
## ⌨️ <a name="usage">Usage Examples</a>
Optimize all JPEG files in a directory:
<!-- eslint-skip -->
```sh
picopt *.jpg
```
Optimize all files and recurse directories:
<!-- eslint-skip -->
```sh
picopt -r *
```
Optimize files, recurse directories, also optimize ePub & CBZ containers,
convert lossless images into WEBP, convert CBR into CBZ.
<!-- eslint-skip -->
```sh
picopt -rx EPUB,CBR,CBZ -c WEBP,CBZ *
```
Optimize files and recurse directories AND optimize comic book archives:
<!-- eslint-skip -->
```sh
picopt -rx CBZ *
```
Optimize comic directory recursively. Convert CBRs to CBZ. Convert lossless
images, including TIFF, to lossless WEBP. Do not follow symlinks. Set
timestamps.
<!-- eslint-skip -->
```sh
picopt -rStc CBZ,WEBP -x TIFF,CBR,CBZ /Volumes/Media/Comics
```
Optimize all files, but only JPEG format files:
<!-- eslint-skip -->
```sh
picopt -f JPEG *
```
Optimize files and containers, but not JPEGS:
<!-- eslint-skip -->
```sh
picopt -f GIF,PNG,WEBP,ZIP,CBZ,EPUB *
```
Optimize files, but not animated gifs:
<!-- eslint-skip -->
```sh
picopt -f PNG,WEBP,ZIP,CBZ,EPUB *
```
Just list files picopt.py would try to optimize:
<!-- eslint-skip -->
```sh
picopt -L *
```
Optimize pictures in my iPhoto library, but only after the last time I did this,
skipping symlinks to avoid duplicate work. Also drop a timestamp file so I don't
have to remember the last time I did this:
<!-- eslint-skip -->
```sh
picopt -rSt -D '2013 June 1 14:00' 'Pictures/iPhoto Library'
```
## 📦 <a name="package">Packages</a>
- [PyPI](https://pypi.python.org/pypi/picopt/)
- [Arch Linux](https://aur.archlinux.org/packages/picopt/)
## 👀 <a name="alternatives">Alternatives</a>
- [imagemin](https://github.com/imagemin/imagemin-cli) looks to be an all in one
cli and gui solution with bundled libraries, so no awkward dependencies.
- [Imageoptim](http://imageoptim.com/) is an all-in-one OS X GUI image
optimizer. Imageoptim command line usage is possible with
[an external program](https://code.google.com/p/imageoptim/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Stars&groupby=&sort=&id=39).
Raw data
{
"_id": null,
"home_page": "https://github.com/ajslater/picopt",
"name": "picopt",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "image, png, jpg, cbz, cbr",
"author": "AJ Slater",
"author_email": "aj@slater.net",
"download_url": "https://files.pythonhosted.org/packages/9a/9a/258d0c631642e00f1403fef74437c3a840209e574fba8f7ef8241504cc03/picopt-4.0.4.tar.gz",
"platform": null,
"description": "# picopt\n\nA multi-format, recursive, multiprocessor aware, command line, lossless image\noptimizer utility that can use external tools for even better optimizing.\n\nPicopt will optionally drop hidden timestamps at the root of your image\ndirectories to avoid reoptimizing images picopt has already optimized.\n\n## \ud83d\udcad <a name=\"philosophy\">Conversion Philosophy</a>\n\n### Warning\n\nPicopt transforms images in place and throws out the old image. Always have a\nbackup of images before running picopt in case you are not satisfied with the\nresults.\n\n### Lossy Images\n\nConverting lossy images rarely makes sense and so picopt only optimizes them in\ntheir current format.\n\n- JPEG images are optimized with MozJpeg's jpegtran.\n- WEBP Lossy images are not optimized. There is no current way to preserve\n information without running it through a lossy process again.\n\n### Lossless Images\n\nLossless WebP images are smaller than PNG, much smaller than GIF and, of course,\na great deal smaller than uncompressed bitmaps like BMP. As such the best\npractice is probably to convert all lossless images to WebP Lossless as now all\nmajor browsers support it. The only downside is that decoding WebP Lossless\ntakes on average 50% more CPU than PNG. All major desktop and mobile browsers\nsupport WEBP. WEBP is the lossless format of choice. Until perhaps JPEG XL\nsupport arrives for browsers.\n\n### Sequenced Images\n\nSequenced Images, like animated GIFs and WebP, most of the time, should be\nconverted to a compressed video format like HEVC, VVC, VP9 or VP10. There are\nseveral situations where this is impractical and so Animated WebP is now a good\nsubstitute.\n\n### Conversion\n\nBy default, picopt does not convert images between formats. You must turn on\nconversion to PNG or WebP explicitly.\n\n## \ud83d\uddbc\ufe0f <a name=\"formats\">Formats</a>\n\n- By default picopt will optimize GIF, JPEG, PNG, and WEBP images.\n- Picopt can optionally optimize SVG images, ZIP, ePub, and CBZ containers.\n- Picopt can convert many lossless images such as BMP, CBR, CUR, DIB, FITS, GIF,\n IMT, PCX, PIXAR, PNG, PPM, PSD, QOI, SGI, SPIDER, SUN, TGA, TIFF, XBM, and XPM\n into PNG and WEBP.\n- Picopt can convert Animated GIF, TIFF, and FLI into Animated PNG or WebP\n files.\n- Picopt can convert Animated GIF, TIFF, FLI, and PNG into Animated WebP files.\n- Picopt can convert MPO to JPEG by stripping secondary images (often thumbnails\n created by cameras) if a primary image exists. (Experimental).\n- Picopt can convert RAR files into Zipfiles and CBR files into CBZ files.\n\nBecause picopt supports so many lossless image formats, to avoid surprises if\nyou specify a conversion target, picopt will only convert GIF and PNG images to\nthe target by default. To convert another format, like BMP, to WEBP you must\nspecify that you want to read the BMP format _and_ that you want to convert it\nto WEBP:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -x BMP -c WEBP big_old.bmp\n```\n\n### JPEG\n\nTo optimize JPEG images at all picopt needs one of\n[mozjpeg](https://github.com/mozilla/mozjpeg) or\n[jpegtran](http://jpegclub.org/jpegtran/) on the path. in order of preference.\n\n### PNG & APNG\n\nPicopt uses an internal oxipng python module to optimize PNG images and convert\nother lossless formats to PNG picopt. The external\n[pngout](http://advsys.net/ken/utils.htm) tool can provide a small extra bit of\ncompression.\n\nAnimated PNGs are optimized with the internal optimizer.\n\n### Animated GIF\n\nGifs and Animated GIFs are optimized with\n[gifsicle](http://www.lcdf.org/gifsicle/) if available. or interaallly if is\nnot. Gifsicle only provides a small advantage over the internal optimizer.\n\n### WebP\n\nWebP lossless formats are optimized with\n[cwebp](https://developers.google.com/speed/webp/docs/cwebp) if available and\nwith the internal optimizer if not. cwebp provides significant improvements over\nthe internal optimizer.\n\n### SVG\n\nPicopt can only optimize SVGs if [svgo](https://github.com/svg/svgo) is on the\npath.\n\n### MPO (Experimental)\n\nPicopt can extract the primary image from a multi JPEG MPO that also contains\nthumbnails and convert the file to an ordinary JPEG. Picopt will also optimize\nthis image if it can. To enable this you must run with `-x MPO -c JPEG`\nSteroscopic MPOs should have no primary image tagged in the MPO directory and be\nunaffected.\n\nThis feature has not been tested with a large variety of MPOs and should be\nconsidered experimental.\n\n### EPub\n\nEPub Books are zip files that often contain images and picopt unpacks and\nrepacks this format natively. Images within the epub are handled by other\nprograms. EPub optimization is not turned on by default. EPub contents are never\nconverted to other formats because it would break internal references to them.\n\n### CBZ & CBR\n\nPicopt uncompresses, optimizes and rezips\n[comic book archive files](https://en.wikipedia.org/wiki/Comic_book_archive). Be\naware that CBR rar archives may only be rezipped into CBZs instead of CBR. Comic\nbook archive optimization is not turned on by default to prevent surprises.\n\n## \ud83d\udce6 <a name=\"install\">Install</a>\n\n### System Dependencies\n\n#### Python\n\nPicopt requires Python 3.10 or greater installed on whichever system you use.\n\nPicopt is most effective with these binary dependencies installed. We must\ninstall these first\n\n#### macOS\n\n<!-- eslint-skip -->\n\n```sh\nbrew install gifsicle mozjpeg svgo webp\n\nln -s $(brew --prefix)/opt/mozjpeg/bin/jpegtran /usr/local/bin/mozjpeg\n```\n\n#### Debian / Ubuntu, Windows Linux Subsystem\n\n<!-- eslint-skip -->\n\n```sh\napt-get install gifsicle python-imaging webp\n```\n\nif you don't want to install mozjpeg using the instructions below then use\njpegtran:\n\n<!-- eslint-skip -->\n\n```sh\napt-get install libjpeg-progs\n```\n\nSee mozjepg, pngout & svgo install instructions below\n\n#### Redhat / Fedora\n\n<!-- eslint-skip -->\n\n```sh\ndnf install gifsicle python3-pillow libwebp-tools\n```\n\nif you don't want to install mozjpeg using the instructions below then use\njpegtran:\n\n<!-- eslint-skip -->\n\n```sh\ndnf install libjpeg-turbo-utils\n```\n\nSee mozjepg, pngout & svgo install instructions below\n\n### Picopt python package\n\n<!-- eslint-skip -->\n\n```sh\npip install picopt\n```\n\n## \u2699\ufe0f <a name=\"programs\">External Programs</a>\n\nPicopt will perform optimization on most lossless formats without using external\nprograms, but much more compression is possible if these external programs are\non your path.\n\n### mozjpeg\n\nmozjpeg offers better compression than libjpeg-progs jpegtran. It may or may not\nbe packaged for your \\*nix, but even when it is, picopt requires that its\nseparately compiled version of jpegtran be symlinked to 'mozjpeg' somewhere in\nthe path.\n\nInstructions for installing on macOS are given above. Some near recent binaries\nfor Windows and Debian x86\n[can be found here](https://mozjpeg.codelove.de/binaries.html). Most Linux\ndistributions still require a more manual installation as elucidated here on\n[Casey Hoffer's blog](https://www.caseyhofford.com/2019/05/01/improved-image-compression-install-mozjpeg-on-ubuntu-server/)\n\n### pngout\n\npngout is a compression tool that can be used for small extra compression. It\ndoes not run on 16 bit PNGs.\n\nIt can be installed on macOS with:\n\n<!-- eslint-skip -->\n\n```sh\nbrew install jonof/kenutils/pngout\n```\n\nIt is not packaged for linux, but you may find the latest binary version\n[on JonoF's site](http://www.jonof.id.au/kenutils). Picopt looks for the binary\nto be called `pngout`\n\n### svgo\n\nsvgo compresses SVGs. Svgo is packaged for homebrew, but picopt can also use it\nif it's installed with npm.\n\n#### On Linux\n\nTo install svgo on Linux you can use the snap tool:\n\n<!-- eslint-skip -->\n\n```sh\nsnap install svgo\n```\n\nOr you can install svgo with npm:\n\n<!-- eslint-skip -->\n\n```sh\nnpm install -G svgo\n```\n\n## \u2328\ufe0f <a name=\"usage\">Usage Examples</a>\n\nOptimize all JPEG files in a directory:\n\n<!-- eslint-skip -->\n\n```sh\npicopt *.jpg\n```\n\nOptimize all files and recurse directories:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -r *\n```\n\nOptimize files, recurse directories, also optimize ePub & CBZ containers,\nconvert lossless images into WEBP, convert CBR into CBZ.\n\n<!-- eslint-skip -->\n\n```sh\npicopt -rx EPUB,CBR,CBZ -c WEBP,CBZ *\n```\n\nOptimize files and recurse directories AND optimize comic book archives:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -rx CBZ *\n```\n\nOptimize comic directory recursively. Convert CBRs to CBZ. Convert lossless\nimages, including TIFF, to lossless WEBP. Do not follow symlinks. Set\ntimestamps.\n\n<!-- eslint-skip -->\n\n```sh\npicopt -rStc CBZ,WEBP -x TIFF,CBR,CBZ /Volumes/Media/Comics\n```\n\nOptimize all files, but only JPEG format files:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -f JPEG *\n```\n\nOptimize files and containers, but not JPEGS:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -f GIF,PNG,WEBP,ZIP,CBZ,EPUB *\n```\n\nOptimize files, but not animated gifs:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -f PNG,WEBP,ZIP,CBZ,EPUB *\n```\n\nJust list files picopt.py would try to optimize:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -L *\n```\n\nOptimize pictures in my iPhoto library, but only after the last time I did this,\nskipping symlinks to avoid duplicate work. Also drop a timestamp file so I don't\nhave to remember the last time I did this:\n\n<!-- eslint-skip -->\n\n```sh\npicopt -rSt -D '2013 June 1 14:00' 'Pictures/iPhoto Library'\n```\n\n## \ud83d\udce6 <a name=\"package\">Packages</a>\n\n- [PyPI](https://pypi.python.org/pypi/picopt/)\n- [Arch Linux](https://aur.archlinux.org/packages/picopt/)\n\n## \ud83d\udc40 <a name=\"alternatives\">Alternatives</a>\n\n- [imagemin](https://github.com/imagemin/imagemin-cli) looks to be an all in one\n cli and gui solution with bundled libraries, so no awkward dependencies.\n\n- [Imageoptim](http://imageoptim.com/) is an all-in-one OS X GUI image\n optimizer. Imageoptim command line usage is possible with\n [an external program](https://code.google.com/p/imageoptim/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Stars&groupby=&sort=&id=39).\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "A multi format lossless image optimizer that uses external tools",
"version": "4.0.4",
"project_urls": {
"Documentation": "https://github.com/ajslater/picopt",
"Homepage": "https://github.com/ajslater/picopt",
"Issues": "https://github.com/ajslater/picopt/issues",
"Source": "https://github.com/ajslater/picopt"
},
"split_keywords": [
"image",
" png",
" jpg",
" cbz",
" cbr"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0248d9a3d91c43ae93631b1a1516c84e9837d9a31017073acf165afb2665d786",
"md5": "ab7de5ab079c296266b0074991fa7b5e",
"sha256": "086a5b2780b4ad5153b31e22b7f602a6e354b3b799c187d24b8ed0f6ea703f0e"
},
"downloads": -1,
"filename": "picopt-4.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ab7de5ab079c296266b0074991fa7b5e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 44483,
"upload_time": "2024-10-16T22:22:29",
"upload_time_iso_8601": "2024-10-16T22:22:29.646560Z",
"url": "https://files.pythonhosted.org/packages/02/48/d9a3d91c43ae93631b1a1516c84e9837d9a31017073acf165afb2665d786/picopt-4.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9a9a258d0c631642e00f1403fef74437c3a840209e574fba8f7ef8241504cc03",
"md5": "ed7592a3765b6917a62370e7d1759636",
"sha256": "72aafb09b158db82d2af4b8d1d99635690ce1d8eee0fd68c0d696b73a155f8aa"
},
"downloads": -1,
"filename": "picopt-4.0.4.tar.gz",
"has_sig": false,
"md5_digest": "ed7592a3765b6917a62370e7d1759636",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 9525417,
"upload_time": "2024-10-16T22:22:31",
"upload_time_iso_8601": "2024-10-16T22:22:31.403841Z",
"url": "https://files.pythonhosted.org/packages/9a/9a/258d0c631642e00f1403fef74437c3a840209e574fba8f7ef8241504cc03/picopt-4.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-16 22:22:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ajslater",
"github_project": "picopt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"lcname": "picopt"
}