Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial (non-profit) use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

    Please read the Pointers For Use on my home page to properly install and customize my scripts.

PICFRAME


Adds a picture frame around an image.

Download Script

last modified: December 15, 2018

Download Frames
tar.gz format
zip format



USAGE: picframe [-f frameid] [-m mattesize] [-c mattecolor] [-b bordersize] [-s shade] [-a adjust] [-o opacity ] [-d distance] infile outfile
USAGE: picframe [-h or -help]

-f .... frameid id number of picture frame; Value are
.......................... between 1 and number of png files in
.......................... picframecorners directory; default=1;
.......................... see below for id to name correspondences
-m .... mattesize ........ surrounding matte thickness in pixels;
.......................... default=0 or no matte
-c .... mattecolor ....... color to use for surrounding matte
.......................... default=cornsilk
-b .... bordersize ....... thickness of black border between image and matte
.......................... default=0 or no border
-s .... shade ............ percent shading to add to the border;
.......................... shade ranges from 1 to 100; integer; default=0
-a .... adjust ........... adjust the brightness, saturation and hue of
.......................... the frame. This is useful as shading reduces the
.......................... saturation. Values are expressed as three integers
.......................... percentage changes separated by commas. See -modulate.
.......................... Default is 100,100,100 for no change.
-o .... opacity .......... inner shadow opacity for upper and left sides;
.......................... 0<=integer<=100; default=50
-d .... distance ......... inner shaddow distance in pixels for upper and
.......................... left sides; integer>=0; if distance=0, then no
.......................... shadow will created; default=0

PURPOSE: To add a picture frame around and image.

DESCRIPTION: PICFRAME adds a picture frame around an image using pictures of actual frames. There is an option to add a black border around the image and/or a colored matte.

ARGUMENTS:

-f frameid ... FRAMEID is the id number for the picture frame. The following id and frame types are allowd: 1) oak, 2) rustic mahogany, 3) light rosewood, 4) light gold, 5) dark rosewood, 6) gold finish, 7) ornate rosewood, 8) onate silver, 9) ornate walnut, 10) maple, 11) ornate gold and 12) mahogany. The default is 1) oak.

-m mattesize ... MATTESIZE is the thicknesses in pixels for the optional matte around the image. The default is 0 or no matte.

-c mattecolor ... MATTECOLOR is the color of the optional matte surrounding the image. Any IM color specification is valid. Be sure to enclose it in double quotes. The default is cornsilk. For colornames see http://imagemagick.org/script/color.php

-b bordersize ... BORDERSIZE is the thickness of the optional black border around the image. The default is 0 or no black border.

-s shade ... SHADE is the percentage shading from an upper left light source. Values range from 0 to 100. Default is 0 or no shading.

-a adjust ... ADJUST affects the brightness, saturation and hue of the frame. It is represented as three integer representing percentage changes separated by commas. This is useful as shading decreases the saturation of the frame. Values greater/less than 100 for the brightness and saturation will increase/decrease them. Values greater/less than 100 for the hue will shift the color towards the green/red. A value of 100,100,100 is the default and will make no change.

-o opacity ... OPACITY is the inner shadow opacity for upper and left sides. Values are integers between 0 and 100. The default=50.

-d distance ... DISTANCE is the inner shaddow distance in pixels for upper and left sides. Values are integers>=0. If distance=0, then no shadow will created. The default=0

NOTE: Be sure to download the picframecorners folder and place it where you want it. Then modify the framedir location in the defaults section just below to point to where you have placed the brcorners folder.

If you want to add your own frames, simply cut out a square section of the lower right corner of a picture frame whose dimensions are the thickness of the frame and place it in the picframecorners directory with a name of "brcorner#.png" where # is the next available integer. All picture corners must be in PNG format.

Thanks to Anthony Thyssen for the shading technique. See http://www.imagemagick.org/Usage/thumbnails/#frame_edge

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


Picture Frame Styles

1) Oak

2) Rustic Mahogany

3) Light Rosewood

4) Light Gold

5) Dark Rosewood

6) Gold Finish

7) Ornate Rosewood

8) Ornate Silver

9) Ornate Walnut

10) Maple

11) Ornate Gold

12) Mahogany



Picture In Frame

Original
http://www.yamabay.com/showpic.asp?n=Monet+Paintings&s=celebrity&id=31044746

Frame 1
Arguments:
-f 1 (default)

Frame 2
Arguments:
-f 2

Frame 1 With Border And Matte
Arguments:
-f 1 -m 20 -b 1

Frame 2 With Border And Matte
Arguments:
-f 2 -m 20 -b 1

Frame 1 With Border, Matte And Shading
Arguments:
-f 1 -m 20 -b 1 -s 25

Frame 1 With Border, Matte, Shading And Saturation
Arguments:
-f 2 -m 20 -b 1 -s 25 -a 100,150,100

Frame 1 With Border, Matte, Shading, Saturation and Green Shift
Arguments:
-f 1 -m 20 -b 1 -s 25 -a 100,150,110

Frame 1 With Border, Matte, Shading, Saturation and Red Shift
Arguments:
-f 2 -m 20 -b 1 -s 25 -a 100,150,90

Frame 1 With Border, Matte, Shading and Shadow
Arguments:
-f 1 -m 20 -b 1 -s 25 -o 50 -d 6

 

 


What the script does for the case of no shading and no adjust is as follows:

  • Starts with the bottom right corner piece of a frame
  • Extrudes the right and bottom sides from the first row
    and first column of the corner
  • Flips and flops the corner and the right and bottom to
    fill out the remaining corners and sides
  • Composites them all together with the image.

This is equivalent to the following IM commands:

  • convert \( -size ${w4}x${h4} xc:white \) \
    \( $brcorner -rotate 180 \) -gravity NorthWest -composite \
    \( $brcorner[1x${h2}+0+0] -filter point -resize $size1 -flip \) -gravity North -composite \
    \( $brcorner -flip \) -gravity NorthEast -composite \
    \( $brcorner[${w2}x1+0+0] -filter point -resize $size2 -flop \) -gravity West -composite \
    \( $infile -bordercolor black -border ${bordersize}x${bordersize} -bordercolor $mattecolor \
    -border ${mattesize}x${mattesize} \) -gravity Center -composite \
    \( $brcorner[${w2}x1+0+0] -filter point -resize $size2 \) -gravity East -composite \
    \( $brcorner -flop \) -gravity SouthWest -composite \
    \( $brcorner[1x${h2}+0+0] -filter point -resize $size1 \) -gravity South -composite \
    \( $brcorner \) -gravity SouthEast -composite \
    $outfile