smally


Namesmally JSON
Version 0.525 PyPI version JSON
download
home_page
SummaryTo compress JPEG, PNG and GIF files losslessly in batch mode
upload_time2023-10-28 11:00:43
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2019 xinlin for smally project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Additional Info: Smally project page https://github.com/xinlin-z/smally Author's python note blog https://www.pynote.net Author's another blog https://www.maixj.net
keywords gif jpeg png batch compress
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            {toc}

Smally is a simple tool to compress JPEG, PNG and GIF files losslessly,
by invoking the famous `jpegtran`, `optipng` and `gifsicle` tools,
in batch mode, in-place and keep mtime unchanged. It is written
in Python, but heavily rely on shell.

## How to Compress

### JPEG

1. Using `jpegtran` to remove all metadata, create a baseline version
and a progressive version.
2. To compare among the original file, baseline and progressive
files, choose the smallest one in size.
3. Whenever possible, choose progressive version.

### PNG

Calling `optipng` to compress PNG, in the most crazy `-o7 -zm1-9` level.

### GIF

Calling `gifsicle` to compress GIF, by using `-O3 --color 256`.

## How to Install

```shell
# install tools on Fedora
$ sudo dnf install libjpeg-turbo-utils optipng gifsicle
# install tools on Ubuntu
$ sudo apt install libjpeg-turbo-progs optipng gifsicle
# install smally
$ pip install smally
```

## How to Use

```shell
# inline help
$ python -m smally -h
# to compress a single file, if option is not presented,
# smally will use file command to get file type info.
$ python -m smally [-j|-p|-g] <pathname>
# to compress a directory
$ python -m smally -r -P<N> <pathname>
# to compress all png file in a directory
$ python -m smally -r -P<N> -p <pathname>
```

`-r`, recursively, it's a command line convention and normally you should
use it when deal with a directory.

`-P<N>`, parallel process number, if it is missing, the logical cpu
count number will be used.

## API

4 APIs provided by smally:

```python
# import
from smally import (jpegtran,
                    optipng,
                    gifsicle,
                    is_jpeg_progressive)
# signature
def jpegtran(pathname: str) -> tuple[int,int]: ...
def optipng(pathname: str) -> tuple[int,int]: ...
def gifsicle(pathname: str) -> tuple[int,int]: ...
def is_jpeg_progressive(pathname: str) -> bool: ...
```

The first int in returned tuple is the byte number saved. It could be zero,
which means no save. The second int is the original file size.

## Screenshot

![smally](/screenshot.png)



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "smally",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "GIF,JPEG,PNG,batch,compress",
    "author": "",
    "author_email": "xinlin-z <xinlin.zhang@hotmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/c6/f008634af1f6ee45762e8c709180ffc82f28a1e9ef34a99b4ce58b5a26cc/smally-0.525.tar.gz",
    "platform": null,
    "description": "{toc}\n\nSmally is a simple tool to compress JPEG, PNG and GIF files losslessly,\nby invoking the famous `jpegtran`, `optipng` and `gifsicle` tools,\nin batch mode, in-place and keep mtime unchanged. It is written\nin Python, but heavily rely on shell.\n\n## How to Compress\n\n### JPEG\n\n1. Using `jpegtran` to remove all metadata, create a baseline version\nand a progressive version.\n2. To compare among the original file, baseline and progressive\nfiles, choose the smallest one in size.\n3. Whenever possible, choose progressive version.\n\n### PNG\n\nCalling `optipng` to compress PNG, in the most crazy `-o7 -zm1-9` level.\n\n### GIF\n\nCalling `gifsicle` to compress GIF, by using `-O3 --color 256`.\n\n## How to Install\n\n```shell\n# install tools on Fedora\n$ sudo dnf install libjpeg-turbo-utils optipng gifsicle\n# install tools on Ubuntu\n$ sudo apt install libjpeg-turbo-progs optipng gifsicle\n# install smally\n$ pip install smally\n```\n\n## How to Use\n\n```shell\n# inline help\n$ python -m smally -h\n# to compress a single file, if option is not presented,\n# smally will use file command to get file type info.\n$ python -m smally [-j|-p|-g] <pathname>\n# to compress a directory\n$ python -m smally -r -P<N> <pathname>\n# to compress all png file in a directory\n$ python -m smally -r -P<N> -p <pathname>\n```\n\n`-r`, recursively, it's a command line convention and normally you should\nuse it when deal with a directory.\n\n`-P<N>`, parallel process number, if it is missing, the logical cpu\ncount number will be used.\n\n## API\n\n4 APIs provided by smally:\n\n```python\n# import\nfrom smally import (jpegtran,\n                    optipng,\n                    gifsicle,\n                    is_jpeg_progressive)\n# signature\ndef jpegtran(pathname: str) -> tuple[int,int]: ...\ndef optipng(pathname: str) -> tuple[int,int]: ...\ndef gifsicle(pathname: str) -> tuple[int,int]: ...\ndef is_jpeg_progressive(pathname: str) -> bool: ...\n```\n\nThe first int in returned tuple is the byte number saved. It could be zero,\nwhich means no save. The second int is the original file size.\n\n## Screenshot\n\n![smally](/screenshot.png)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2019 xinlin for smally project  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  Additional Info: Smally project page https://github.com/xinlin-z/smally Author's python note blog https://www.pynote.net Author's another blog https://www.maixj.net",
    "summary": "To compress JPEG, PNG and GIF files losslessly in batch mode",
    "version": "0.525",
    "project_urls": {
        "homepage": "https://github.com/xinlin-z/smally"
    },
    "split_keywords": [
        "gif",
        "jpeg",
        "png",
        "batch",
        "compress"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7b81b251ce0d80b15053cbf01d4558a1adbb6de9d109a10138b5240f15204b9",
                "md5": "8fc027a40da8950d1c0e232e3232714c",
                "sha256": "19c433751a6b27e0167e7ab04a10dbc5de184ab18f83f9e580727e264fbc0060"
            },
            "downloads": -1,
            "filename": "smally-0.525-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8fc027a40da8950d1c0e232e3232714c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6112,
            "upload_time": "2023-10-28T11:00:18",
            "upload_time_iso_8601": "2023-10-28T11:00:18.024984Z",
            "url": "https://files.pythonhosted.org/packages/a7/b8/1b251ce0d80b15053cbf01d4558a1adbb6de9d109a10138b5240f15204b9/smally-0.525-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73c6f008634af1f6ee45762e8c709180ffc82f28a1e9ef34a99b4ce58b5a26cc",
                "md5": "b649fcbd4c0e8e3f1fff0fb2a2c703c1",
                "sha256": "bfb3d9207d3a53cd79db661c278a885b54c8ddd3f370fbb0fd1781e534304dee"
            },
            "downloads": -1,
            "filename": "smally-0.525.tar.gz",
            "has_sig": false,
            "md5_digest": "b649fcbd4c0e8e3f1fff0fb2a2c703c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3334867,
            "upload_time": "2023-10-28T11:00:43",
            "upload_time_iso_8601": "2023-10-28T11:00:43.250904Z",
            "url": "https://files.pythonhosted.org/packages/73/c6/f008634af1f6ee45762e8c709180ffc82f28a1e9ef34a99b4ce58b5a26cc/smally-0.525.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-28 11:00:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xinlin-z",
    "github_project": "smally",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "smally"
}
        
Elapsed time: 0.12914s