I'm trying to do several actions on an image (resize, crop, add some blank white space on bottom).
Then I'm trying to add a caption in that empty white space.
I want to use mogrify
so I can edit the existing file, rather than creating a new file (it will be in high volume).
This is giving me an error, I'm not quite sure how to do this. It does work with convert
though.
magick mogrify -resize 300x -crop 300x200+0+50 -extent 300x290 input.jpg -size 300x90 -gravity SouthWest -font "Arial" -pointsize 24 -fill black caption:'dis some really long shit that goes on 3 lines onmg how will it ever the' -composite -quality 100
magick is for IM 7 and convert is for IM 6. If you need to do mogrify, then you must prepare the text image in a separate command and save it. Then use -draw in mogrify to do the composite. But if you are processing only one image at a time, then convert is the more flexible option and will allow compound statements and composite. Mogrify does not allow both input and output images. It takes an asterix wild card (or one file) and processes it writing the output over the input, unless you provide an output directory. See the links I mentioned in my last comment.
Here are 3 ways to do it. The first two use magick on IM 7 and the third creates a text image using magick and then uses magick mogrify to composite it using -draw. I recommend that you use the second method and if you have many images to process, then write a script loop over each input image.
Input:
This uses composite:
magick lena.jpg -resize 300x -crop 300x200+0+50 +repage -extent 300x290 \( -size 300x90 -gravity SouthWest -font "Arial" -pointsize 24 -fill black caption:'This is some really long stuff that goes on 3 lines so how will it ever fit' \) -compose over -composite -quality 100 lena_result1.jpg
This is simpler with no extent, just append:
magick lena.jpg -resize 300x -crop 300x200+0+50 +repage \( -size 300x90 -gravity SouthWest -font "Arial" -pointsize 24 -fill black caption:'This is some really long stuff that goes on 3 lines so how will it ever fit' \) -append -quality 100 lena_result2.jpg
This creates the text image and saves as tmp.png:
magick -size 300x90 -gravity SouthWest -font "Arial" -pointsize 24 -fill black caption:'This is some really long stuff that goes on 3 lines so how will it ever fit' text.png
Then it uses -draw to composite the test.png image onto the one input to magick mogrify, which is always specified last in the command. The output is written over this input:
magick mogrify -resize 300x -crop 300x200+0+50 +repage -extent 300x290 -draw "gravity southwest image over 0,0 0,0 'text.png'" lena2.jpg
In the above, I have used Unix syntax. For Windows, remove the \ from before ( and before ).