Menu

Watermarks

Anonymous

Introduction

This is a nautilus script for put watermarks on images selected in Nautilus

Author: Julio C. Neves <julioneves@openoffice.org>

Additional software:

Details

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#
#  Put watermark on images selected in Nautilus.
#+ Dependencies:
#+      - yad
#+      - ImageMagick

Geometry='Top Left!Top Right!Bottom Left!Bottom Right!Top!Bottom!Left!Right!Center!Tiled'

# get value of decimal point in current locale
eval $(locale -ck LC_NUMERIC | grep decimal_point)

while :
do
#### Now the magic of YAD ####
    Choices=$(yad --title "Put a watermark" --form      \
        --width 500 --dialog-sep --image xfce4-keyboard \
        --field "Watermark file:FL"                     \
        --field "Watermark position:CB"                 \
        --field "% tranparency:NUM"                     \
        --button gtk-ok:0 --button gtk-cancel:1         \
        "" "$Geometry" '20!0..100!5') || {
        yad --text "Abnormal end" --button gtk-ok
        exit 1
    }
    IFS='|'
    read File Position Transparency <<< "$Choices"
    Transparency=${Transparency%$decimal_point*}
    [ -f "$File" ] && break
    yad --text "No watermark file         " \
        --image dialog-error                \
        --button gtk-ok:0
done

Position=$(case "$Position" in
        ("Top Left")        echo northwest  ;;
        ("Top Right")       echo northeast  ;;
        ("Bottom Left")     echo southwest  ;;
        ("Bottom Right")    echo southeast  ;;
        (Top)           echo north  ;;
        (Bottom)        echo south  ;;
        (Left)          echo west   ;;
        (Right)         echo east   ;;
        (Center)        echo center ;;
        (*)         echo tile   ;;
esac)   # Bash 4.0++ dont need to open parentesys
Position=$([[ $Position == tile ]] && echo -tile || echo -gravity $Position)
IFS='
'       # Because the name of some files has spaces

i=0
TotArqs=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | wc -l) 
#  In the next for a numeric echo moves the 
#+ progress bar and an echo beginning with a # 
#+ changes the header.
#+ Now the big trick ImageMagick + nautilus + YAD
for Arq in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do 
    #  Os 2 echo a seguir são para atualizar o progress
    echo $((++i * 100 / $TotArqs))
    echo "# Putting a watermark on ${Arq##*/}"
    Arq=$(sed 's/ /\\ /g' <<< "$Arq") # Escape blanks (because of eval)
    eval composite -watermark $Transparency $Position "$File" "$Arq" "$Arq"
    sleep 1
done | yad --progress --title "Wait, ImageMagick working..." --text ' ' --width 500 --auto-close --auto-kill

Discussion

  • Anonymous

    Anonymous - 2011-04-13

    Originally posted by: alzingr...@gmail.com

    Victor,

    That's still me ...

    I succeeded in executing the "composite" command alone on the command line this way : "eval composite -watermark ..."

    but the shell does not work and returns the following error code : "composite: missing an image filename `/home/g2a/Documents/DBA/images' @ composite.c/CompositeImageCommand?/1609."

    I have added the following lines at the beginning of the shell export MAGICK_HOME="/usr/lib/ImageMagick?-6.5.7 NAUTILUS_SCRIPT_SELECTED_FILE_PATHS=/home/g2a/Documents/DBA/images export NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

    I have a File.JPEG ( watermark file ) in my $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS directory as well as a TEST.JPEG to put the watermark on.

    Thanks for your help

    Jean-michel, Nemours, FRANCE

     
  • Anonymous

    Anonymous - 2011-04-13

    Originally posted by: ananasik

    actually, this is not my script. i don't use gnome applications (nautilus in this case) and can't check this issue. but i send your question to author

     
  • Anonymous

    Anonymous - 2011-04-13

    Originally posted by: alzingr...@gmail.com

    Thank you. Jean-michel

     
  • Anonymous

    Anonymous - 2011-04-13

    Originally posted by: julio.ne...@gmail.com

    Hi Jean-michel You could't set a value to the NAUTILUS_SCRIPT_SELECTED_FILE_PATHS variable because NAUTILUS_SCRIPT_SELECTED_FILE_PATHS, contains the selected files (at Nautilus) with absolute paths and line break between them. But it has a problem, does not work on files that are on the desktop and only works for local files, I mean, only works on network smb:// if you mount the network folder using mount and smbfs.

    Julio Neves (from Brazil)

     
  • Anonymous

    Anonymous - 2011-04-14

    Originally posted by: alzingr...@gmail.com

    Julio, Victor, Thanks for your help. I succeeded in updating some pictures but I had to suppress the "--auto-kill" parameters on the yad call. It seems to prevent the script to work normally. When I needed to work on a specific directory ( that I put in the script to then launch the script on the command line ) instead of selecting files before, I had also to add a ls command to allow the loop to work properly which is normal I guess given the selection was not made the usual way through a nautilus screen.

    Nice tools

    Bye

    Jean-michel, Nemours, FRANCE

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.