author | František Kučera <franta-hg@frantovo.cz> |
Mon, 17 Nov 2014 23:44:59 +0100 | |
changeset 22 | 75a0eba0ba97 |
parent 20 | 4e4ad30c17d4 |
permissions | -rw-r--r-- |
franta-hg@0 | 1 |
copy-image-resizer |
franta-hg@0 | 2 |
------------------ |
franta-hg@0 | 3 |
|
franta-hg@0 | 4 |
An CLI tool written in Java for resizing images. |
franta-hg@0 | 5 |
Recursively transfers a tree of files and directories and resizes images. |
franta-hg@0 | 6 |
|
franta-hg@0 | 7 |
|
franta-hg@0 | 8 |
Why? |
franta-hg@0 | 9 |
---- |
franta-hg@0 | 10 |
|
franta-hg@0 | 11 |
If you have fully-fledged operating system like some GNU/Linux distribution, |
franta-hg@0 | 12 |
you will probably use better tool for resizing images. |
franta-hg@0 | 13 |
In Debian or Ubuntu you can easilly install ImageMagick: |
franta-hg@0 | 14 |
apt install imagemagick |
franta-hg@0 | 15 |
and resize images: |
franta-hg@0 | 16 |
convert ${input} -resize 1200x1200 -quality 80 ${output}; |
franta-hg@0 | 17 |
or write some shell script around it. |
franta-hg@0 | 18 |
|
franta-hg@0 | 19 |
But if you need a multiplatform tool with minimal requirements, |
franta-hg@0 | 20 |
the copy-image-resizer might be useful. |
franta-hg@0 | 21 |
|
franta-hg@0 | 22 |
|
franta-hg@20 | 23 |
Instalation |
franta-hg@20 | 24 |
----------- |
franta-hg@0 | 25 |
|
franta-hg@20 | 26 |
cd java/copy-image-resizer/ |
franta-hg@20 | 27 |
ant |
franta-hg@0 | 28 |
|
franta-hg@20 | 29 |
compiled program is in: dist/copy-image-resizer.jar |
franta-hg@20 | 30 |
|
franta-hg@20 | 31 |
you can run it directly: |
franta-hg@20 | 32 |
java -jar dist/copy-image-resizer.jar |
franta-hg@20 | 33 |
or install it somewhere and run through th wrapper script: |
franta-hg@20 | 34 |
scripts/copy-image-resizer.sh |
franta-hg@20 | 35 |
(link it somewhere on your $PATH as „copy-image-resizer“) |
franta-hg@20 | 36 |
|
franta-hg@20 | 37 |
TODO: .rpm and .deb packages |
franta-hg@20 | 38 |
|
franta-hg@20 | 39 |
Usage |
franta-hg@20 | 40 |
----- |
franta-hg@20 | 41 |
|
franta-hg@20 | 42 |
copy-image-resizer supports these options: |
franta-hg@20 | 43 |
|
franta-hg@20 | 44 |
--input-dir (mandatory) |
franta-hg@20 | 45 |
one parameter: path to the input directory |
franta-hg@20 | 46 |
|
franta-hg@20 | 47 |
--output-dir (mandatory) |
franta-hg@20 | 48 |
one parameter: path to the output directory |
franta-hg@20 | 49 |
|
franta-hg@20 | 50 |
--size (mandatory, can be used multiple times to generate multiple resolutions) |
franta-hg@20 | 51 |
1. parameter: width (integer) |
franta-hg@20 | 52 |
2. parameter: height (integer) |
franta-hg@20 | 53 |
3. parameter: resizeSmaller (boolean) whether smaller images should be also scaled |
franta-hg@20 | 54 |
|
franta-hg@20 | 55 |
--size-named (alternative to --size) |
franta-hg@20 | 56 |
1. parameter: width (integer) |
franta-hg@20 | 57 |
2. parameter: height (integer) |
franta-hg@20 | 58 |
3. parameter: resizeSmaller (boolean) |
franta-hg@20 | 59 |
4. parameter: directory (string) output sub-directory for this resolution (default in --size is WIDTHxHEIGHT e.g. 64x64) |
franta-hg@20 | 60 |
|
franta-hg@20 | 61 |
--skip-errors (optional, alternative to --skip-errors-silently) |
franta-hg@20 | 62 |
no parameters |
franta-hg@20 | 63 |
errors will be just logged and program will fail at the end if any errors |
franta-hg@20 | 64 |
(default behavior is: fail on first error) |
franta-hg@20 | 65 |
|
franta-hg@20 | 66 |
--skip-errors-silently (optional, alternative to --skip-errors) |
franta-hg@20 | 67 |
no parameters |
franta-hg@20 | 68 |
errors will be just logged and program will report success even if there were any errors |
franta-hg@20 | 69 |
|
franta-hg@20 | 70 |
|
franta-hg@20 | 71 |
|
franta-hg@20 | 72 |
Example: |
franta-hg@20 | 73 |
|
franta-hg@20 | 74 |
copy-image-resizer --input-dir MyPhotos/ --output-dir MyBlog/ --size 800 600 false --size 1600 1200 false --size-named 300 300 false thumnails |
franta-hg@20 | 75 |
|
franta-hg@20 | 76 |
Will generate three output resolutions in separate directories: „MyBlog/800x600“, „MyBlog/1600x1200“ and „MyBlog/thumbnails“ |
franta-hg@20 | 77 |
|
franta-hg@20 | 78 |