You can use ImageMagick's built-in fx
operator to do maths for you, without involving bash
mathematics, bc
or eval
.
Like this:
persp=$(convert image.jpg -format "0,0 75,0 0,%h 0,%[fx:int(h/2)] %w,0,%w,200 %w,%h %[fx:int(w*0.75)],%h" info:)
echo $persp
0,0 75,0 0,900 0,450 1440,0,1440,200 1440,900 1080,900
Then do:
convert image.jpg ... -distort Perspective "$persp" ... distorted.jpg
Oh, for those bonus points... ;-)
convert image.jpg -format "0,0 75,0 0,%h 0,%[fx:int(h/2)] %w,0,%w,200 %w,%h %[fx:int(w*0.75)],%h" info: > points.txt
convert image.jpg ... -distort Perspective @points.txt distorted.jpg