I'd like to know syntax for such task: I have one file which is "dimensions template" - it has its own WxH. IM should read this dimensions and use them for resizing of other file ONLY.
As for now, I have such command working:
magick template.jpg image-to-resize.jpg -resize "x%[fx:int(h/2)]" second-image-resized.jpg
But calling this command outputs two images - first and second taken as input - resized. How to tell 'fx' that it should read dimensions from first input image?
I use IM v7.1.1 on Ubuntu 22.04.
EDIT: in the meantime I asked the same on IM discussion board on GitHub. I got excellent solution from snibgo: https://github.com/ImageMagick/ImageMagick/discussions/7090#discussioncomment-8395013
This command starts by reading the template image and the input image. Next it sets a variable using an FX expression to calculate the resize. Then it deletes the template image before resizing and outputting the result.
magick template.jpg image.jpg -set option:high %[fx:u.h/2] -delete 0 -resize x%[high] resized.jpg
The "u.h" in the expression specifies that the height of the first image, the template, is used for the calculation. The command simply deletes that template before the resize operation.