#image #converter #cli #front-end #image-cli

app sic

sic stands for simple image converter and is a partial front-end for the image crate

8 releases (5 breaking)

0.7.2 Sep 8, 2018
0.7.1 Sep 6, 2018
0.7.0 Aug 24, 2018
0.6.0 Aug 10, 2018
0.2.2 Jun 10, 2018

#42 in Images

Download history 8/week @ 2018-08-04 38/week @ 2018-08-11 10/week @ 2018-08-18 18/week @ 2018-08-25 2/week @ 2018-09-01 29/week @ 2018-09-08 10/week @ 2018-09-15 4/week @ 2018-09-22 25/week @ 2018-09-29 2/week @ 2018-10-06 8/week @ 2018-10-13 85/week @ 2018-10-20 3/week @ 2018-10-27

56 downloads per month

MIT license

94KB
1.5K SLoC

Simple Image Converter (sic)

Converts a single image from one format to another (plus some other operations).

The image conversion is actually done by the awesome image crate :balloon:. sic is a small command line frontend which supports a portion of the conversion operations supported by the image crate.

It was initially created to try out another awesome Rust library: clap :tada:

Install

With cargo install: cargo install --force sic

Pre build binary: see releases

From the source of this repo:

  • Setup rust and cargo with (for example) rustup, a nightly version is required.
  • Clone this repo: git clone https://github.com/foresterre/sic.git
  • Switch to this repo: cd sic
  • Build a release: cargo build --release

Usage

Convert an image from one format to another, for example from PNG to JPG.

  • In general: sic <input> <output>
  • Example: sic input.png output.jpg

Covert an image from one format to another while not caring about the output file extension.

  • In general sic --force-format "<format>" <input> <output> (or sic --force-format "<format>" <input> <output>)
  • Example sic --force-format png input.bmp output.jpg (Note: output.jpg will have the PNG format even though the extension is jpg.)

Note: supported forced formats currently are: bmp, gif, ico, jpg (always 80%), pnm (P6 only). Support for other versions of supported formats is planned.

Apply image operations to an image.

  • In general: sic --script "<operations>" <input> <output>
  • Example sic input.png output.jpg --script "flip_horizontal; blur 10; resize 250 250"

The separator ; within the image operation script is optional. It exists to provide clarity.

Note: resize applies a gaussian sampling filter on resizing. This is currently the only sampling filter available (i.e. not changeable, all resize operations will be done with the gaussian sampling filter).

Image operations availability:

operations syntax available (from version) description
blur blur <uint> [E-BLUR] Yes (0.5.0) Performs a Gaussian blur on the image (more info)
brighten brighten <int> [E-BRIGHTEN] Yes (0.7.0)
contrast contrast <fp> [E-CONTRAST] Yes (0.7.0)
crop No You can use `resize `` with values smaller or equal to the current image size for now.
filter3x3 filter3x3 <args9> [E-FILTER3X3] Yes (0.7.0)
flip horizontal fliph [E-FLIPH] Yes (0.5.0) Flips the image on the horizontal axis
flip vertical flipv [E-FLIPV] Yes (0.5.0) Flips the image on the horizontal axis
gray scale grayscale [E-GRAYSCALE] Yes (0.7.0)
hue rotate huerotate <int> [E-HUEROTATE] Yes (0.7.0) Rotate's the hue, argument is in degrees. Rotates <int>%360 degrees.
invert invert [E-INVERT] Yes (0.7.0)
resize resize <uint> <uint> [E-RESIZE] Yes (0.5.0) Resize the image using a Gaussian sampling filter (more info, filter)
rotate90 rotate90 [E-ROTATE90] Yes (0.7.0)
rotate180 rotate180 [E-ROTATE180] Yes (0.7.0)
rotate270 rotate270 [E-ROTATE270] Yes (0.7.0)
unsharpen unsharpen <fp> <int> [E-UNSHARPEN] Yes (0.7.0)

legend:

<uint> means any 32 bit unsigned integer is required as parameter input.
<int> means any 32 bit signed integer is required as parameter input.
<fp> means any 32 bit floating point number is required as parameter input.
<args9> means `<fp> <fp> <fp> | <fp> <fp> <fp> | <fp> <fp> <fp>` where the `|` separator is optional. If the separator is used, white space should surround the separator. The separators can only be used like in the example, so one separator after each of the first two triplets.

Syntax examples: For each example: each of the lines are valid syntactically and the full examples are valid syntactically as well.

[E-BLUR], Blur operation example script:

blur 10;

[E-BRIGHTEN], Brighten operation example script:

brighten 10;
brighten -10;

[E-CONTRAST], Contrast operation example script:

contrast -10;
contrast 10;
contrast 1.35;

[E-FILTER3X3] Filter3x3 operation example script:

filter3x3 10.0 9.0 8.0 | 7.5 6.5 5.5 | 4 3 2;
filter3x3 10.0 9.0 8.0 7.5 6.5 5.5 4 3 2;
filter3x3 10.0 9.0 8.0 7.5 6.5 5.5 4 3 2
filter3x3 10.0 9.0 8.0 7.5 6.5 5.5 4 3 2 filter3x3 12.0 29.0 28 27.5 26 25.5 14 3 2

[E-FLIPH]. Flip horizontal operation example script:

fliph;

[E-FLIPV]. Flip vertical operation example script:

flipv;

[E-GRAYSCALE]. Gray scale operation example script:

grayscale;

[E-HUEROTATE]. Hue rotate operation example script:

huerotate 10;
huerotate -10;

[E-INVERT]. Invert operation example script:

invert;

[E-RESIZE]. Resize operation example script:

resize 10 10;
resize 1 1;
resize 80 180;

[E-ROTATE90]. Rotate 90 degree operation example script:

rotate90;

[E-ROTATE180]. Rotate 180 degree operation example script:

rotate180;

[E-ROTATE270]. Rotate 270 degree operation example script:

rotate270;

[E-UNSHARPEN]. Unsharpen operation example script:

unsharpen -12.3 -12;
unsharpen -10.0 12;
unsharpen 12.3 1;
unsharpen 10 1;

Suggestions, Questions, Bugs

Feel free to open an issue :mailbox_with_mail: if you have a suggestion, a question or found a bug =).

:guitar: :trumpet: :violin: :saxophone:

Dependencies

~3.5MB
~63K SLoC