Skip to content

shinokada/consize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buy Me a Coffee at ko-fi.com

Consize: CONvert and reSIZE

Consize

PWA Shield Created by Shin Okada License

Consize

Introduction

Consize converts and resizes image formats. It supports converting PNG, JPG, JPEG and WEBP files. The script is built with the help of ImageMagick, webp, and optipng.

Installation

Consize can be installed using Homebrew, Awesome package manager or by cloning/downloading the repository.

Homebrew

brew tap shinokada/consize
brew install consize

Awesome package manager

After installing Awesome package manager:

awesome install shinokada/consize

Debian/Ubuntu

Download the latest release from the releases page.

cd /path/to/dir
sudo apt install consize_x.x.x-1_all.deb

Clone or download

Please clone or download from the repo.

git clone https://github.com/shinokada/consize.git

Dependencies

Consize requires the following dependencies to be installed:

  • zsh
# debian/ubuntu
sudo apt install zsh
  • ImageMagick
# mac
brew install imagemagick
# debian/ubuntu
sudo apt -y install imagemagick
  • webp
# mac
brew install webp
# debian/ubuntu
sudo apt -y install webp
  • jpegoptim
# mac
brew install jpegoptim
# debian/ubuntu
sudo apt -y install jpegoptim
  • optipng
# mac
brew install optipng
# debian/ubuntu
sudo apt -y install optipng
  • svgo
npm install -g svgo
  • svgexport
npm install -g svgexport

Usage

Options

Options Description
-i Input directory option has the default value of the current directory (.)
-o Output directory option has no default value
-q Quality option has the default value of 100

Convert all image files (PNG/JPG/JPEG) to WEBP

consize img2webp -o path/to/outputdir

Convert JPG/JPEG files

To WEBP:

consize jpg2webp -o path/to/outputdir

To PNG:

consize jpg2png -o path/to/outputdir

Optimize

The following commands will run recursively in the current directory or the directory specified by the -o option.

consize optimize_jpg -o outputDir
consize optimize_png -o outputDir
consize optimize_svg -o outputDir

Organize Files

The consize organize_files command will create directories based on the file extensions and move all files into their respective directories. The default output directory is oraganized.

consize organize_files -o 'outputdir'

Convert PNG

To JPG:

consize png2jpg -o path/to/outputdir

To WEBP:

consize png2webp -o path/to/outputdir

Resize JPG/PNG/WEBP

Resize command requires -w, --width option and it all images is created in the resized directory.

consize resize -w 540 -h 284

To set only the width:

consize resize -w 540

Convert SVG

Converting SVG files require the -w, --width option.

To JPG:

consize svg2jpg -w 50

To PNG:

consize svg2png

Convert WEBP

To JPG:

consize webp2jpg

To PNG:

consize webp2png

Tests

cd spec
./test_functions.sh

Credits

Article

Converting Images to WebP From Terminal

PWA: Fast & Offline

This website can be downloaded and installed on your device for offline access as a Progressive Web App.

To install a PWA, look for the "Add to Home Screen" option in the browser's menu or settings. On most mobile devices, this option can be found by visiting the website, then selecting the "Options" or "Menu" button in the browser, and looking for the "Add to Home Screen" option. On some desktop browsers, right-click on the page and select "Install".