Home > Enterprise >  Windows - ImageMagick v7 set text to 20% of parents width
Windows - ImageMagick v7 set text to 20% of parents width

Time:06-20

Using Windowns I would like to achive to set my copyright to my Images. This already works. But the problem is, that is always is differently big, relative to the image.

I use this command:

script.cmd

magick.exe convert IMAGE.jpg -quality 100 -pointsize 200x -background none -fill white -font Roboto label:"© Copyright" -trim -gravity center -gravity SouthEast -geometry  120 110 -composite IMAGE_COPYRIGHT.jpg

The problem is, that I alway want it to take up 15% of the parents width, so it is not to big on portrait pictures. On landscape it looks good, but 15% would be better anyway.

Is there a way to do this in batch/cmd on Windows? I already tried %[fx:w/6] (about 16%), but that didn't work aswell.

CodePudding user response:

In place of adjusting pointsize, leave it off and set the width in -size "%[fx:0.15*w]x". Note the "x"

for %%x in (*.jpg;*.jpeg;*.png;*.webp) DO magick.exe convert "%~dp0%%x" -quality 100 \( -size "%[fx:0.15*w]x" -background none -fill white -font Roboto label:"© Copyright" -trim -gravity center \) -gravity SouthEast -geometry  120 110 -composite "%~dp0copyright\%%x"

CodePudding user response:

Solution is to not use magic convert, but just magic. In my case magic.exe. Otherwise it will run in ImageMagickv6 compatibility mode.

After this -size "%%[fx:0.15*w]x" will work. Please note the two %.

Thats @ALL for helping!

  • Related