Fred's ImageMagick Scripts


    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial 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:


Generates a profile of an image row or column

Download Script

last modified: August 27, 2013

USAGE: profile [-r row] [-c col] [-w width] infile [outfile]
USAGE: profile [-h or -help]

-r ...... row ..... row of image to profile; rows start at 0; default=0
-c ...... col ..... column of image to profile; cols start at 0
................... script will use only one of -r or -c; the last one
................... specified in the command line; default is -r 0
-w ...... width ... width of profile; width>=0; recommend 100 to 300;
................... default=0 means use the full length of the row or column;
................... however it will be slow if length is greater than 300;
-l ...... label ... enable or disable label; label=on or off; default=on
-f ...... format .. one graph or three for RGB image; format=1 or 3; default=3
outfile ........... if not specified, outfile will be named from the infile name

PURPOSE: To generate a profile of an image row or column.

DESCRIPTION: PROFILE generates an output image which is composed of the separate profiles from each channel of the input image for a given row or column. Profile values will be plotted in the range of 0 to 100 as percent graylevel. A label is included which specifies: the min and max values along the row or column for each channel (in the same range), the size of the profile and the row or column number.


-r row is the row of image to profile. Rows start at 0. The default=0.

-c col is the column of image to profile. Rows start at 0. The default=0.

Note, the script will use only one of -r or -c, whichever is the last one specified in the command line. The default is to use -r 0.

-w width is the width of profile. Values are width=0 or between 100 to 300. The default=0 means to use the full length of the row or column. However processing will be slow if length is greater than 300.

-l label is a flag to enable or disable the annotation labeling. The values for label are on or off. The default is lable=on.

-f format determines whether to have 3 individual graphs for each channel or one graph with all three channel profiles superimposed. Values for format are 1 or 3. The default is format=3.

If no outfile is specified, then outfile will be named as infilename_profile.gif, where the suffix has been removed from infile to generate infilename.

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.


Profile Of Grayscale LUT Image

Grayscale LUT

(-r 0 -w 0)

Profile Of True Color Image


-r 64

-c 64

Profile Display Variations


-f 3 -l on -r 120

-f 3 -l off -r 120

-f 1 -l on -r 120

-f 1 -l off -r 120

What the script does is as follows:

  • Extracts each channel for the row or column specified
  • Converts the image data for the row or column into text values
  • Creates an array of x,y values where x is the position in the
    row or column and y is the grayscale value at that position
  • Makes a graph image out of each channel
  • Labels each graph with min and max values
  • Appends all 3 channels and Labels it with size and row/column number

This is equivalent to the following IM commands for the case of
a 256x1 grayscale (LUT) image with arguments -r 0

  • convert $tmpA[256x1+0+0] $tmp0
  • convert $tmp3 -fill white -gravity center \
    -extent 260x104 \
    -fill none -stroke black \
    -draw "rectangle 0,0 ${width2},${height2}" $tmp3
  • convert -size 276x110 xc:white $tmp3 \
    -gravity center -compose over -composite $tmp0
  • montage -label \
    "min=$min\nmax=$max\n\nProfile\n256x100\n\n$line $lineval" \
    -geometry +0+0 $tmp0 $outfile