eneko / crop

Command line tool to scale and crop images maintaining aspect ratio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crop

crop

A command line tool to scale and crop images maintaining aspect ratio.

From local file:

$ crop original.png 1920 1080
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 1920x1080
πŸ“ Resized image saved to: original_1920x1080.png

From web:

$ crop http://www.example.com/original.png 1920 1080

Custom filename:

$ crop http://www.example.com/original.png 1920 1080 -o output.png

Usage

OVERVIEW: Resize and Crop images

USAGE: crop <filename|url> <width> <height>

OPTIONS:
  --output, -o
             Output filename
  --help     Display available options

POSITIONAL ARGUMENTS:
  filename   Filename or URL
  height     Output height in pixels
  width      Output width in pixels

Installation

Download the latest release and save in a folder in your executable path, for example on /usr/local/bin:

$ curl -O https://github.com/eneko/crop/releases/download/0.0.1/crop.zip
$ unzip crop.zip
$ install -d /usr/local/bin
$ install -C -m 755 crop /usr/local/bin/crop

Scripting

Command line tools are great for scripting. Need to scale and crop an image to multiple sizes? Say no more!

$ vim generate-appletv-images.sh
#!/usr/bin/env sh

ORIGINAL=$1

crop $ORIGINAL 2320  720 -o TopShelf_Wide.jpg
crop $ORIGINAL 4640 1440 -o TopShelf_Wide@2x.jpg
crop $ORIGINAL 1920  720 -o TopShelf.jpg
crop $ORIGINAL 3840 1440 -o TopShelf@2x.jpg
crop $ORIGINAL 1280  768 -o AppIcon_AppStore.jpg
crop $ORIGINAL 2560 1536 -o AppIcon_AppStore@2x.jpg
crop $ORIGINAL  400  240 -o AppIcon_Small.jpg
crop $ORIGINAL  800  480 -o AppIcon_Small@2x.jpg
crop $ORIGINAL 1920 1080 -o Launch_Image.jpg
crop $ORIGINAL 3840 2160 -o Launch_Image@2x.jpg

Save with :wq and update permissions:

$ chmod 755 generate-appletv-images.sh

Now, when running the script, it will automatically generate all images at once.

$ ./generate-appletv-images.sh original.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 2320x720
πŸ“ Resized image saved to: TopShelf_Wide.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 4640x1440
πŸ“ Resized image saved to: TopShelf_Wide@2x.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 1920x720
πŸ“ Resized image saved to: TopShelf.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 3840x1440
πŸ“ Resized image saved to: TopShelf@2x.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 1280x768
πŸ“ Resized image saved to: AppIcon_AppStore.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 2560x1536
πŸ“ Resized image saved to: AppIcon_AppStore@2x.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 400x240
πŸ“ Resized image saved to: AppIcon_Small.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 800x480
πŸ“ Resized image saved to: AppIcon_Small@2x.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 1920x1080
πŸ“ Resized image saved to: Launch_Image.jpg
πŸ™ Original image size: 4284x2844
πŸ™ Resized image size: 3840x2160
πŸ“ Resized image saved to: Launch_Image@2x.jpg

About

Command line tool to scale and crop images maintaining aspect ratio

License:MIT License


Languages

Language:Swift 92.8%Language:Makefile 7.2%