Search code examples
imagemagickeditinggimp

Adding border to multiple images using gimp?


I have around 100 pictures that i want to add white border to it all at once. I use Linux and also use gimp ,.. please suggest me something to do so online of offline. and one more thing that i have tried convert option on imagemagick but nothing happen.


Solution

  • If you want to do 100 all at once you will be best off using ImageMagick's mogrify command like this to add a 10 pixel white border around all images:

    mogrify -mattecolor white -frame 10x10 image*.jpg
    

    If the images are not all in a single directory, you can do the following which will do the same thing across all subdirectories of the one you are currently in:

    find . -name \*.jpg -exec convert "{}" -mattecolor white -frame 10x10 "{}" \;
    

    Obviously you can change the 10 to a different number of pixels if you wish.

    Please make a backup before using this as I may have misunderstood your needs.

    Updated

    If you want a drop shadow, you really need to be working with PNG rather than JPG since the former supports transparency and the latter doesn't - but IM can convert your JPEGs to PNGs anyway. I use the following command for drop shadows:

    convert image.jpg \( -clone 0 -background black -shadow 80x3+0+8 \) -reverse -background none -layers merge +repage image.png
    

    So, I would apply that to a pile of images like this:

    #!/bin/bash
    for f in *.jpg; do
       new=${f%%jpg}png    # Work out new name = original name minus "jpg" + "png"
       echo Processing $f into $new
       convert "$f" \( -clone 0 -background black -shadow 80x3+0+8 \) -reverse -background none -layers merge +repage "$new"
    done