More than once I've found myself opening Gimp just to resize an image, usually a screen capture, to a more e-mail or phone friendly size. More than once I've also found myself wishing to be able to do it in an easier way.
The (self-imposed) restrictions are:
- It has to work in Windows 10 (current working environment)
- It has to use Cygwin (echo, awk, sed, cygpath, dirname, basename)
- It has to use Image Magick (convert)
I remembered having made something like this some years ago but for merging PDF files, but didn't have the code nor the setup instructions and also remembered that the folders and the file names couldn't have spaces for the script to work.
This time I was determined to make it work with spaces, and multiple files.
Then the fight started.
Finding a way to receive and properly diferentiate every argument was a pain, but it worked in the end.
Supposing you already have Cygwin installed and working, you can clone this repo or download just the script. For the sake of this instruction, we are going to say that the script is in /home/user/folder/resize.sh
Remember to chmod 755 /home/user/folder/resize.sh
[Win]+R shell:sendto
to open the windows folder where the Send To shortcuts live.
Create a new one called Shrink with the following target:
C:\cygwin64\bin\bash.exe -c "source /home/user/folder/resize.sh" %*
Right button on an image and you should select Send To and then Shrink and the magic[1] should happen.
The resized file will have a suffix _half.
For instance, if you resize morning_glory.jpg
the smaller file would be called morning_glory_half.jpg
[1]: The magic would look like a black command screen.