I have the following bash script (.sh) that’s working just fine in Unix. I’d like to convert into a batch (.bat) file for use with ImageMagick for Windows but I’m having a bit of trouble with the conversion.
Original GIT repo for the Unix script(s):
https://github.com/AndreyChernyh/imagemagick-filters
ImageMagick version for Windows:
http://www.imagemagick.org/download/binaries/ImageMagick-6.7.0-Q16-windows.zip
#!/bin/bash
SOURCE=$1
# Prepare
rm -f result.jpg source_copy.jpg mask.png
convert $SOURCE -fill rgba\(251,243,213,1.0\) -colorize 100% fill.jpg
convert assets/earlybird/mask.png -resize `identify -format "%wx%h" $SOURCE`\! mask.png
cp $SOURCE source_copy.jpg
# Run
convert fill.jpg $SOURCE -compose multiply -gravity center -composite - |
convert - -modulate 101,68,100 - |
convert - -gamma 1.19 - |
convert - -channel red +level 10.5%,100% - |
convert - -modulate 105,120 - |
convert - -modulate 100,83,100 - |
convert - -level 0%,92%,0.92 - |
convert mask.png - -compose ColorBurn -composite - |
convert mask.png - -compose Multiply -composite result.jpg
# Cleanup
rm -f source_copy.jpg fill.jpg
# Open
open $SOURCE result.jpg
This is what I have so far, but it’s not working as intended as I’m not sure what the batch file equivalent of multiple command line arguments are: e.g., “\” or “|” or whether it’s even possible. I read somewhere that the equivalent is a caret “^” but again, I’m not 100% sure how to implement it properly.
@echo off
set SOURCE=%1
del result.jpg
del source_copy.jpg
del mask.png
convert.exe %SOURCE% -fill rgba(251,243,213,1.0\) -colorize 100% fill.jpg
convert.exe assets\earlybird\mask.png -resize 1024x768 mask.png
copy %SOURCE% source_copy.jpg
convert.exe fill.jpg %SOURCE% -compose multiply -gravity center -composite - ^
convert.exe - -modulate 101,68,100 - ^
convert.exe - -gamma 1.19 - ^
convert.exe - -channel red +level 10.5%,100% - ^
convert.exe - -modulate 105,120 - ^
convert.exe - -modulate 100,83,100 - ^
convert.exe - -level 0%,92%,0.92 - ^
convert.exe mask.png - -compose ColorBurn -composite - ^
convert.exe mask.png - -compose Multiply -composite result.jpg
del source_copy.jpg
del fill.jpg
WORKING CODE:
This is what I’ve done after applying @Gabe‘s answer. No errors and it’s working flawlessly!
@echo off
set SOURCE=%1
del result.jpg
del source_copy.jpg
del mask.png
conv %SOURCE% -fill rgba(251,243,213,1.0) -colorize 100%% fill.jpg
conv assets\earlybird\mask.png -resize 604x453 mask.png
copy %SOURCE% source_copy.jpg
conv fill.jpg %SOURCE% -compose multiply -gravity center -composite - |^
conv - -modulate 101,68,100 - |^
conv - -gamma 1.19 - |^
conv - -channel red +level 10.5%%,100%% - |^
conv - -modulate 105,120 - |^
conv - -modulate 100,83,100 - |^
conv - -level 0%%,92%%,0.92 - |^
conv mask.png - -compose ColorBurn -composite - |^
conv mask.png - -compose Multiply -composite result.jpg
del source_copy.jpg
del fill.jpg
You’re pretty close. The big problems I see are that you have an extra
\inrgba(...), you need to escape your%signs (like%%), and you need to put|before the line continuation characters (like|^). Try this: