Code: Select all
convert fsr.jpg \( watermark.jpg -resize 480 \) -append -verbose fsr-marked.jpg
Code: Select all
convert fsr.jpg -set option:davewidth '%w' \( watermark.jpg -resize %[davewidth] \) -append -verbose fsr-marked.jpg
Thanks,
Dave
Code: Select all
convert fsr.jpg \( watermark.jpg -resize 480 \) -append -verbose fsr-marked.jpg
Code: Select all
convert fsr.jpg -set option:davewidth '%w' \( watermark.jpg -resize %[davewidth] \) -append -verbose fsr-marked.jpg
If you're willing to move into ImageMagick v7, your command may work just the way you're trying to do it. I have beta version "ImageMagick 7.0.0-0 Q16 x64 2016-01-17" installed on a Windows 7 64 machine, and the "-resize %[davewidth]" uses that "-set option:davewidth" variable just fine. I've been using those same types of operators in several scripts for a couple months without any problems.djaquay wrote:I'm trying to use convert to append two images. I want the 2nd image to match the width of the first. [...] What am I missing here? Is there a better technique?
I was writing my reply while you were posting this.fmw42 wrote:I believe that IM 7 will allow resize to use fx expressions
Code: Select all
magick input.jpg \( watermark.jpg -resize %[fx:100+200] \) -composite output.jpg
Code: Select all
magick input.jpg -set option:my_w %[w] \( watermark.jpg -resize %[my_w] \) -composite output.jpg
Code: Select all
magick input.jpg -set option:my_w %[w] \( watermark.jpg -resize %[fx:my_w+200] \) -composite output.jpg
I do not know the limitation of using -fx expressions, but for this one, why not just domagick input.jpg -set option:my_w %[w] \( watermark.jpg -resize %[fx:my_w+200] \) -composite output.jpg
Code: Select all
magick input.jpg -set option:my_w %[fx:w+200] \( watermark.jpg -resize %[fx:my_w] \) -composite output.jpg
It's not even so much about the FX expressions for what you described, but to use those "-set option:variable" variables in your resize operators, etc., can be quite useful.djaquay wrote:I'm willing to upgrade to v7. I'll be running this on a Mac. I'm not seeing that on the downloads page, would MacPorts support building that version? (I'm really new to Macs, doing this for my wife, so all pointers for this would be greatly appreciated).
Yep, that's how I usually handle it when the situation is that straightforward. It can be trickier when I'm wanting to do other calculations using that value further along in the script, like maybe after a "-trim" operation or sizing to percentages where the results aren't necessarily known. It's usually do-able, but sometimes it means working far enough ahead to establish the values for those "-set option:..." variables before the %w or %h change for instance.fmw42 wrote:I do not know the limitation of using -fx expressions, but for this one, why not just do
Code: Select all
magick input.jpg -set option:my_w %[fx:w+200] \( watermark.jpg -resize %[fx:my_w] \) -composite output.jpg
I use a *nix emulator running the "bash" shell, which should be the default shell on most current Macs. The code below should get you what you want by using a shell variable as fmw42 suggested..djaquay wrote:Or is there a similar way to do what I want in v6?
Code: Select all
IMG="input.jpg"
WATERMARK="watermark.jpg"
WIDTH=`convert "${IMG}" -format %w info:`
convert "${IMG}" \( "${WATERMARK}" -resize "${WIDTH}"x \) -append "${IMG%.*}-marked.jpg"
Code: Select all
WATERMARK="watermark.png"
for IMG in *.jpg ; do
WIDTH=`convert "${IMG}" -format %w info:`
convert "${IMG}" \( "${WATERMARK}" -resize "${WIDTH}"x \) -append "${IMG%.*}-marked.jpg"
done
Code: Select all
convert fsr.jpg \( watermark.jpg -resize `convert fsr.jpg -format %w info:`x \) -append fsr-marked.jpg