Giter VIP home page Giter VIP logo

imageopt's Introduction

imageOpt

A few scripts to help convert/optimize images.

This is a set of image optimizing tools/helpers. Nothing fancy or advanced, but just to make it easier to use. 2 scripts are to create/convert files, and the other ones to optimize images.

I used a GUI tool before, but decided to move over to using these scripts instead. Much easier and more convinient, and I can use the same set of scripts in both GNU/Linux and macOS. You can use them as they are, or perhaps together with other scripts - as helpers.

Install

Install the files to /usr/local/bin, or to any other location. Just make sure it's added to PATH.

I use /usr/local/xbin for these scripts, so...

$ cd /path/to/imageOpt/files
$ sudo install -v -m755 -o0 -g0 mk* *opt /usr/local/xbin

Dependencies

You'll need to have these programs installed:

  • convert (ImageMagick), or magick (ImageMagick v7),
  • jpegoptim
  • optipng
  • gifsicle

Each scripts will abort if any dependecies are missing.

Refer to your package manager (pacman, dnf, apt, port, etc), or compile from source.

Usage

mkjpg, mkthumb

Both are using ImageMagick (magick(IM7) or convert(IM6)), and sips(macOS) to create the files.

$ mkjpg -h
# Usage:
#   mkjpg [ % ] file.png        Default is 100 (%)
#   mkjpg 60 file.png           60%
#   mkjpg **/{more,files}.png   Mulltiple images
#   mkjpg -h                    Show help

$ mkthumb -h
# Usage:
#   mkthumb file.jpg            Result: file_250px.jpg
#   mkthumb 400 file.jpg        Result: file_400px.jpg
#   mkthumb **/{foo,bar}.jpg    Multiple images
#   mkthumb -h                  Show help

jpgopt

jpgopt is using jpegoptim and mkjpg (above). Use 1 or more files, or even the double star ** to recursively run it from where you're at.

$ jpgopt -h
# Usage:
#   jpgopt [ % ] file.jpg       Default is 100 (%)
#   jpgopt 60 file.jpg          60% quality
#   jpgopt **/{more,files}.jpg  More files
#   jpgopt -h                   Show help

The line used by jpegoptim looks like this:

jpegoptim -m${_q} -ftPv -s "${_img}";

You can also run jpgopt on your PNG images, to batch convert->optimize your images in one take. It uses mkjpg for that. That saves some time.

pngopt

pngopt is using optipng, and works like jpgopt.

$ pngopt -h
# Usage:
#   pngopt [-v] <file(s)>       1 or more files
#   pngopt -h                   Show help

The line used by optipng looks like this:

optipng -strip all -quiet -o7 "${file}" -out "${file}.opt";

-o7 is quite a hard setting, it may take some time on larger files.

If the optimized file doesn't get smaller than the original - it'll keep the original instead.

gifopt

gifopt is using gifsicle. I don't use it that much - just wanted something simular to the 2 ones above.

$ gifopt -h
# Usage:
#   gifopt [-v] [-c <int>] <file(s)>        1 or more files
#   gifopt -h                               Show help

The line used by optipng looks like this:

gifsicle ${C}-O3 "${file}" -o "${file}.opt";

Contributing

  1. Fork it (https://gitlab.com/iefdev/imageOpt/forks/new)
  2. Create your feature branch (git switch -c feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Merge Request

imageopt's People

Contributors

iefdev avatar

Watchers

 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.