GithubHelp home page GithubHelp logo

smilepngquant's Introduction

SmilePngquant

That is a bridge of pngquant for python3

What's new 1.1.1

  • add default pngquant sdk path in constructor
  • verify pngquant sdk path

Download

Find package

Or build from github

git clone --recursive git://github.com/kornelski/pngquant.git
cd pngquant
make
sudo make install

Find

which pngquant

$ /usr/local/bin/pngquant

Check version

pngquant --version

$ 2.17.0 (September 2021)

Start to code

from smilepngquant.PNGQuant import PNGQuant

# initialize
smile    = PNGQuant()
or
smile    = PNGQuant('/usr/local/bin/pngquant')

*** by default the application located in /usr/local/bin/pngquant

*** it's able to set to another location via

smile.setPngQuant(path= '/home/winny/pngquant')

test a filename

quality value starts 20 to 100, and it's integer

smile.compress(
  filename  = '/home/winny/Download/kara.png'
  , quality = 80
)

verify before use

if smile.isError():
  print(f'Everything is okay, the file name is: {smile.getFilename()}')

else:
  print(f'{smile.getErrorMessage()}')

Options

  • dirname: can be None set coy to a new directory for the new file

  • newFilename: can be None set a new copy name

Both can set any value, or None, or one of them.

Let check the example:

Ex 1

smile.compress(
  filename      = '/home/winny/Download/kara.png'
  , quality     = 80
  # move to new directory
  , dirname     = '/home/winny/Document/'
  , newFilename = 'jojo'
)

Ex 2

smile.compress(
  filename      = '/home/winny/Download/kara.png'
  , quality     = 80
  # move to new directory
  , dirname     = '/home/winny/Document/'
)

Ex 3

smile.compress(
  filename      = '/home/winny/Download/kara.png'
  , quality     = 80
  # move to new directory
  , newFilename = 'jojo'
)

It is also available on https://pypi.org/project/smilepngquant
To Support my work, please donate me via Buy me a PizzaBuy me a Coffee

smilepngquant's People

Contributors

sitthykun avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.