1. Thank you!!!

    Gabriel from Argentina.

  2. Martin

    does'nt work for me. regardless of which path I use for the watermark graphic, I get an error when running the script that it cant open my watermark.png , no file or directory. i have my file in home/myname/Pictures/watermark.png and this is the path I have entered in the script.


    • Did you try it with a leading / on the path?

      Or try


  3. Damian

    Nice article! May be you shuld use basename instead of pipe and cut but I'll give a try.


    • Linerd

      basename requires you to provide the extension you want to strip, so you can't make it generic for all image types. Perhaps a loop could be written to figure out the correct extension, but it seems like it would be more work than my current code.

      On the other hand, my script assumes that the only '.' in the file name is between the name and the extension, so it's not perfect either.


  4. I'm having some issues; i'm completely new to Bash scripts. I'm getting an error:

    shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

    Any thoughts?

    • Linerd

      Surfrock66 - did you perhaps have several terminals open to different directories and delete the working directory of one of the other terminals? You might get this message if you try to run the script from a directory that no longer exists. A google search on the error suggests some possible causes.

      I don't think the error has anything to do with the program itself.


  5. Hi,

    I found a Webapplication that does batch watermarking (upto 20 images) and it has lot of options to customize the watermark.




  6. "@ Kim – Interesting. I haven’t gotten into perl yet, so I don’t quite follow everything that’s going on. I’m guessing that chomp is a perl specific command?"

    chomp gets rid of the "new line" character that is included when you hit the "Enter/Return" button after submitting data. In this case, the year. The "convert" command is a ImageMagick command (man imagemagick for details).

  7. Jose_X

    I would change the first script to run only after Y/y. This way if the person types "stop" or "help" or "no" or "" etc, they won't have to worry.

    BTW, you can avoid being there to type "y" by doing: yes | thescript


  8. Nice work!

    I wrote a similar script that copies


    Yours is more concise, but mine was written for the specific purpose of creating a directory of smaller, watermarked images within the current directory. Let me know what you think!

    • Linerd

      @ Duane - Nice script. It looks like it could be done a little more efficiently. I like the ls | grep -ic jpg part. That's a neat trick to count the files. I like your watermark image too. I'll have to try making one like that in GIMP.

      The composite command should work fine if you just overwrite the file:
      composite -gravity SouthEast $watermark "$i" "$i"
      Then you can skip the rm command to clean up.

      @ Kim - Interesting. I haven't gotten into perl yet, so I don't quite follow everything that's going on. I'm guessing that chomp is a perl specific command?

      @ both - I guess what sets my script apart is the handling of multiple image file types. There's a lot going on in file -i * | grep image | awk -F':' '{ print $1 }' | while read IMAGE.
      file -i * - lists the files and shows file MIME type.
      grep image - filters the list for image files
      awk -F':' '{ print $1 }' - cuts the file name from the list item (everything before the ":" )
      while read IMAGE - takes the file name output from awk and stores it in $IMAGE

      I tested on a directory with .gif, .jpg, .png, .tiff files. File names with spaces work.


  9. Here are mine. Resized, thumbnailed, and watermarked at the same time:



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.