Watermark as Percentage of Image Size

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Post Reply
Trenthee
Posts: 6
Joined: Wed Aug 12, 2015 11:29 am

Watermark as Percentage of Image Size

Post by Trenthee »

EDIT: I just realized I should have posted this in the NConvert section.Perhaps it can be moved, because I'm not allowed to delete it.

In XnViewMP there is an option in Batch Processing to watermark an image and resize the watermark/logo to a percentage of the image on which the watermark/logo is to appear. In using the Export for Nconvert option I received the following output:

Code: Select all

nconvert -wmopacity 100 -wmfile "/home/images/logo.png" -wmflag top-left
As you can see there is no information on what command XNViewMp used to make the watermark a percentage of the image size.

I then added to the code to make it work in CLI:

Code: Select all

nconvert -out jpeg -wmopacity 100 -wmflag top-left -wmfile "/home/images/logo.png" *jpg
I've tried placing

Code: Select all

-resize 20% 20%
in various positions in the above code, but no luck getting it to work.
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: [NConvert] Watermark as Percentage of Image Size

Post by cday »

The most recent NConvert help file listing I have to hand doesn't show 'Percentage (width)' so it probably hasn't been added yet, if you wish you could make a request in a separate thread for it to be added.

A possible workaround might be to make a resized copy of the watermark file in a separate code line, and then run the two lines as a batch file; if the images to be watermarked vary in size, you could probably put a loop around those two lines. However, thinking about it more, I'm not sure if the watermark file could simply be resized in that way, although there might be a way of doing it. But if the required percentage resizes are fixed it should be easier.

Alternatively, if the images to be watermarked could all be resized to the same fixed pixel dimensions, the same size watermark could then be applied to each scaled image.
Trenthee
Posts: 6
Joined: Wed Aug 12, 2015 11:29 am

Re: [NConvert] Watermark as Percentage of Image Size

Post by Trenthee »

Thanks cday, I decided to use Imagemagick for this. The following Imagemagick code gets the job done:

Code: Select all

pct=23
amt=`convert -ping image.jpg -format "%[fx:$pct*min(w,h)/100]" info:`
convert image.jpg \( logo.png -resize $amt \) -gravity northwest -compose over -composite_watermark.png
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: [NConvert] Watermark as Percentage of Image Size

Post by xnview »

Trenthee wrote: Fri Mar 22, 2019 9:17 pm Thanks cday, I decided to use Imagemagick for this. The following Imagemagick code gets the job done:
need to be added...
Pierre.
Post Reply