- NAME
- SYNOPSIS
- FUNCTION DESCRIPTIONS
  - AllocateString
  - AppendImageFormat
  - BaseFilename
  - CloneString
  - ConvertTextToUnicode
  - ExpandFilename
  - ExpandFilenames
  - FormatString
  - GetGeometry
  - GlobExpression
  - IsAccessible
  - IsDirectory
  - Latin1Compare
  - ListColors
  - ListFiles
  - LocaleFilename
  - LSBFirstReadLong
  - LSBFirstReadShort
  - LSBFirstWriteLong
  - LSBFirstWriteShort
  - MSBFirstOrderLong
  - MSBFirstOrderShort
  - MSBFirstReadShort
  - MSBFirstReadLong
  - MSBFirstWriteLong
  - MSBFirstWriteShort
  - MultilineCensus
  - ParseGeometry
  - PostscriptGeometry
  - ReadByte
  - ReadDataBlock
  - SetClientName
  - StringToArgv
  - StringToList
  - Strip
  - SystemCommand
  - TemporaryFilename
  - TranslateText
  - WriteByte

# NAME

utility - ImageMagick Utility Methods

# SYNOPSIS

char* AllocateString(constchar*source)

void AppendImageFormat(constchar*format,char*filename)

     B<BaseFilename>(name)

unsigned int CloneString(char**destination,constchar*source)

unicode= ConvertTextToUnicode(text,count)

     B<ExpandFilename>(filename)

status= ExpandFilenames(argc,argv)

void FormatString(char*string,constchar*format,...)

     B<GlobExpression>(expression,pattern)

unsigned int IsAccessible(constchar*filename)

unsigned int IsDirectory(constchar*filename)

unsignedlong LSBFirstReadLong(Image*image)

unsignedshort LSBFirstReadShort(Image*image)

unsignedlong LSBFirstWriteLong(Image*image,constunsignedlongvalue)

unsignedlong LSBFirstWriteShort(Image*image,constunsignedshortvalue)

int Latin1Compare(constchar*p,constchar*q)

filelist= ListColors(pattern,number_colors)

filelist= ListFiles(directory,pattern,number_entries)

void LocaleFilename(char*filename)

void MSBFirstOrderLong(registerchar*p,constunsigned intlength)

void MSBFirstOrderShort(registerchar*p,constunsigned intlength)

unsignedlong MSBFirstReadLong(Image*image)

unsignedshort MSBFirstReadShort(Image*image)

unsignedlong MSBFirstWriteLong(Image*image,constunsignedlongvalue)

unsignedlong MSBFirstWriteShort(Image*image,constunsignedshortvalue)

int MultilineCensus(constchar*label)

voidDestroy PostscriptGeometry(char*geometry)

int ReadByte(Image*image)

char* SetClientName(constchar*name)

char** StringToArgv(constchar*text,int*argc)

char** StringToList(constchar*text)

void Strip(char*data)

int SystemCommand(constunsigned intverbose,constchar*command)

void TemporaryFilename(char*filename)

unsignedlong WriteByte(Image*image,constcharvalue)

# FUNCTION DESCRIPTIONS

## AllocateString

Method AllocateString allocates memory for a string and copies the source string to that memory location (and returns it).

The format of the AllocateString method is:

            char *AllocateString(const char *source)

A description of each parameter follows:

allocated_string:

  Method AllocateString returns a copy of the source string.

source:

  A character string.

## AppendImageFormat

Method AppendImageFormat appends the image format type to the filename. If an extension to the file already exists, it is first removed.

The format of the AppendImageFormat method is:

            void AppendImageFormat(const char *format,char *filename)

A description of each parameter follows.

format:

  Specifies a pointer to an array of characters. This is the format of the image.

filename:

  Specifies a pointer to an array of characters. The unique file name is returned in this array.

## BaseFilename

Method BaseFilename removes the path name component and any extensions.

The format of the BaseFilename function is:

            BaseFilename(name)

A description of each parameter follows:

name:

  Specifies a pointer to a character array that contains the name.

## CloneString

Method CloneString allocates memory for the destination string and copies the source string to that memory location.

The format of the (void) CloneString method is:

            unsigned int CloneString(char **destination,const char *source)

A description of each parameter follows:

status:

  Method CloneString returns True is the string is cloned, otherwise False is returned.

destination:

  A pointer to a character string.

source:

  A character string.

## ConvertTextToUnicode

Method ConvertTextToUnicode converts an ASCII text string to Unicode and returns the Unicode translation and the character count. Normal characters are just copied. However, escaped hex codes are interpreted before converting to Unicode (e.g. \0x30a3 is 12451 in the Unicode character set).

The format of the ConvertTextToUnicode function is:

            unicode=ConvertTextToUnicode(text,count)

A description of each parameter follows:

unicode:

  Method ConvertTextToUnicode returns a pointer to an unsigned short array representing the Unicode translation of the ASCII string.

text:

  Specifies a pointer to a character array that contains the text to convert.

count:

  The number of characters that were translated from ASCII to Unicode is returned in this unsigned integer pointer.

## ExpandFilename

Method ExpandFilename expands '~' in a filename.

The format of the ExpandFilename function is:

            ExpandFilename(filename)

A description of each parameter follows:

filename:

  Specifies a pointer to a character array that contains the filename.

## ExpandFilenames

Method ExpandFilenames checks each argument of the command line vector and expands it if they have a wildcard character. For example, *.jpg might expand to: bird.jpg rose.jpg tiki.jpg.

The format of the ExpandFilenames function is:

            status=ExpandFilenames(argc,argv)

A description of each parameter follows:

argc:

  Specifies a pointer to an integer describing the number of elements in the argument vector.

argv:

  Specifies a pointer to a text array containing the command line arguments.

## FormatString

Method FormatString prints formatted output of a variable argument list.

The format of the FormatString method is:

            void FormatString(char *string,const char *format,...)

A description of each parameter follows.

string:

  Method FormatString returns the formatted string in this character buffer.

format:

  A string describing the format to use to write the remaining arguments.

## GetGeometry

Method GetGeometry parses a geometry specification and returns the width, height, x, and y values. It also returns flags that indicates which of the four values (width, height, xoffset, yoffset) were located in the string, and whether the x and y values are negative. In addition,

The format of the GetGeometry method is:

        int GetGeometry(const char *image_geometry,int *x,int *y,
          unsigned int *width,unsigned int *height)

A description of each parameter follows:

flags:

  Method GetGeometry returns a bitmask that indicates which of the four values were located in the geometry string.

image_geometry:

  Specifies a character string representing the geometry specification.

x,y:

  A pointer to an integer. The x and y offset as determined by the geometry specification is returned here.

width,height:

  A pointer to an unsigned integer. The width and height as determined by the geometry specification is returned here.

## GlobExpression

Method GlobExpression returns True if the expression matches the pattern.

The format of the GlobExpression function is:

            GlobExpression(expression,pattern)

A description of each parameter follows:

expression:

  Specifies a pointer to a text string containing a file name.

pattern:

  Specifies a pointer to a text string containing a pattern.

## IsAccessible

Method IsAccessible returns True if the file as defined by filename is accessible.

The format of the IsAccessible method is:

            unsigned int IsAccessible(const char *filename)

A description of each parameter follows.

status:

  Method IsAccessible returns True is the file as defined by filename is accessible, otherwise False is returned.

filename:

  Specifies a pointer to an array of characters. The unique file name is returned in this array.

## IsDirectory

Method IsDirectory returns True if the file as defined by filename is a directory. Once MetroWerks write a `stat(2)` function, we can remove the `chdir(2)` function.

The format of the IsAccessible method is:

            unsigned int IsDirectory(const char *filename)

A description of each parameter follows.

status:

  Method IsDirectory returns True is the file as defined by filename is a directory, otherwise False is returned.

filename:

  Specifies a pointer to an array of characters. The unique file name is returned in this array.

## Latin1Compare

Method Latin1Compare compares two null terminated Latin-1 strings, ignoring case differences, and returns an integer greater than, equal to, or less than 0, according to whether first is lexicographically greater than, equal to, or less than second. The two strings are assumed to be encoded using ISO 8859-1.

The format of the Latin1Compare method is:

            int Latin1Compare(const char *p,const char *q)

A description of each parameter follows:

p:

  A pointer to the string to convert to Latin1 string.

q:

  A pointer to the string to convert to Latin1 string.

## ListColors

Method ListColors reads the X client color database and returns a list of colors contained in the database sorted in ascending alphabetic order.

The format of the ListColors function is:

            filelist=ListColors(pattern,number_colors)

A description of each parameter follows:

filelist:

  Method ListColors returns a list of colors contained in the database. If the database cannot be read, a NULL list is returned.

pattern:

  Specifies a pointer to a text string containing a pattern.

number_colors:

  This integer returns the number of colors in the list.

## ListFiles

Method ListFiles reads the directory specified and returns a list of filenames contained in the directory sorted in ascending alphabetic order.

The format of the ListFiles function is:

            filelist=ListFiles(directory,pattern,number_entries)

A description of each parameter follows:

filelist:

  Method ListFiles returns a list of filenames contained in the directory. If the directory specified cannot be read or it is a file a NULL list is returned.

directory:

  Specifies a pointer to a text string containing a directory name.

pattern:

  Specifies a pointer to a text string containing a pattern.

number_entries:

  This integer returns the number of filenames in the list.

## LocaleFilename

Method LocaleFilename replaces the contents of the string pointed to by filename by a unique file name relative to the directory.

The format of the LocaleFilename method is:

            void LocaleFilename(char *filename)

A description of each parameter follows.

filename:

  Specifies a pointer to an array of characters. The unique file name is returned in this array.

## LSBFirstReadLong

Method LSBFirstReadLong reads a long value as a 32 bit quantity in least-significant byte first order.

The format of the LSBFirstReadLong method is:

            unsigned long LSBFirstReadLong(Image *image)

A description of each parameter follows.

value:

  Method LSBFirstReadLong returns an unsigned long read from the file.

image:

  The address of a structure of type Image.

## LSBFirstReadShort

Method LSBFirstReadShort reads a short value as a 16 bit quantity in least-significant byte first order.

The format of the LSBFirstReadShort method is:

            unsigned short LSBFirstReadShort(Image *image)

A description of each parameter follows.

value:

  Method LSBFirstReadShort returns an unsigned short read from the file.

image:

  The address of a structure of type Image.

## LSBFirstWriteLong

Method LSBFirstWriteLong writes a long value as a 32 bit quantity in least-significant byte first order.

The format of the LSBFirstWriteLong method is:

            unsigned long LSBFirstWriteLong(Image *image,const unsigned long value)

A description of each parameter follows.

count:

  Method LSBFirstWriteLong returns the number of unsigned longs written.

image:

  The address of a structure of type Image.

value:

  Specifies the value to write.

## LSBFirstWriteShort

Method LSBFirstWriteShort writes a long value as a 16 bit quantity in least-significant byte first order.

The format of the LSBFirstWriteShort method is:

            unsigned long LSBFirstWriteShort(Image *image,const unsigned short value)

A description of each parameter follows.

count:

  Method LSBFirstWriteShort returns the number of unsigned longs written.

image:

  The address of a structure of type Image.

value:

  Specifies the value to write.

## MSBFirstOrderLong

Method MSBFirstOrderLong converts a least-significant byte first buffer of integers to most-significant byte first.

The format of the MSBFirstOrderLong method is:

            void MSBFirstOrderLong(register char *p,const unsigned int length)

A description of each parameter follows.

p:

  Specifies a pointer to a buffer of integers.

length:

  Specifies the length of the buffer.

## MSBFirstOrderShort

Method MSBFirstOrderShort converts a least-significant byte first buffer of integers to most-significant byte first.

The format of the MSBFirstOrderShort method is:

            void MSBFirstOrderShort(register char *p,const unsigned int length)

A description of each parameter follows.

p:

  Specifies a pointer to a buffer of integers.

length:

  Specifies the length of the buffer.

## MSBFirstReadShort

Method MSBFirstReadShort reads a short value as a 16 bit quantity in most-significant byte first order.

The format of the MSBFirstReadShort method is:

            unsigned short MSBFirstReadShort(Image *image)

A description of each parameter follows.

value:

  Method MSBFirstReadShort returns an unsigned short read from the file.

image:

  The address of a structure of type Image.

## MSBFirstReadLong

Method MSBFirstReadLong reads a long value as a 32 bit quantity in most-significant byte first order.

The format of the MSBFirstReadLong method is:

            unsigned long MSBFirstReadLong(Image *image)

A description of each parameter follows.

value:

  Method MSBFirstReadLong returns an unsigned long read from the file.

image:

  The address of a structure of type Image.

## MSBFirstWriteLong

Method MSBFirstWriteLong writes a long value as a 32 bit quantity in most-significant byte first order.

The format of the MSBFirstWriteLong method is:

            unsigned long MSBFirstWriteLong(Image *image,const unsigned long value)

A description of each parameter follows.

count:

  Method MSBFirstWriteLong returns the number of unsigned longs written.

value:

  Specifies the value to write.

image:

  The address of a structure of type Image.

## MSBFirstWriteShort

Method MSBFirstWriteShort writes a long value as a 16 bit quantity in most-significant byte first order.

The format of the MSBFirstWriteShort method is:

            unsigned long MSBFirstWriteShort(Image *image,const unsigned short value)

A description of each parameter follows.

value:

  Specifies the value to write.

file:

  Specifies the file to write the data to.

## MultilineCensus

Method MultilineCensus returns the number of lines within a label. A line is represented by a \n character.

The format of the MultilineCenus method is:

            int MultilineCensus(const char *label)

A description of each parameter follows.

label:

  This character string is the label.

## ParseGeometry

Method ParseImageGeometry parses a geometry specification and returns the width, height, x, and y values. It also returns flags that indicates which of the four values (width, height, xoffset, yoffset) were located in the string, and whether the x and y values are negative. In addition,

The format of the ParseImageGeometry method is:

        int ParseGeometry(const char *geometry,int *x,int *y,unsigned int *width,
          unsigned int *height)

A description of each parameter follows:

flags:

  Method ParseImageGeometry returns a bitmask that indicates which of the four values were located in the geometry string.

image_geometry:

  Specifies a character string representing the geometry specification.

x,y:

  A pointer to an integer. The x and y offset as determined by the geometry specification is returned here.

width,height:

  A pointer to an unsigned integer. The width and height as determined by the geometry specification is returned here.

## PostscriptGeometry

Method PostscriptGeometry replaces any page mneumonic with the equivalent size in picas.

The format of the PostscriptGeometry method is:

            void DestroyPostscriptGeometry(char *geometry)

A description of each parameter follows.

page:

  Specifies a pointer to an array of characters. The string is either a Postscript page name (e.g. A4) or a postscript page geometry (e.g. 612x792+36+36).

## ReadByte

Method ReadByte reads a single byte from the image file and returns it.

The format of the ReadByte method is:

            int ReadByte(Image *image)

A description of each parameter follows.

value:

  Method ReadByte returns an integer read from the file.

image:

  The address of a structure of type Image.

## ReadDataBlock

Method ReadBlobBlock reads data from the image file and returns it. The amount of data is determined by first reading a count byte. The number or bytes read is returned.

The format of the ReadBlobBlock method is:

        unsigned long ReadBlobBlock(Image *image,char *data)

A description of each parameter follows:

count:

  Method ReadBlobBlock returns the number of bytes read.

image:

  The address of a structure of type Image.

data:

  Specifies an area to place the information requested from the file.

## SetClientName

Method SetClientName sets the client name if the name is specified. Otherwise the current client name is returned.

The format of the SetClientName method is:

            char *SetClientName(const char *name)

A description of each parameter follows:

client_name:

  Method SetClientName returns the current client name.

status:

  Specifies the new client name.

## StringToArgv

Method StringToArgv converts a text string into command line arguments.

The format of the StringToArgv method is:

            char **StringToArgv(const char *text,int *argc)

A description of each parameter follows:

argv:

  Method StringToArgv returns the string list unless an error occurs, otherwise NULL.

text:

  Specifies the string to segment into a list.

argc:

  This integer pointer returns the number of arguments in the list.

## StringToList

Method StringToList converts a text string into a list by segmenting the text string at each carriage return discovered. The list is converted to HEX characters if any control characters are discovered within the text string.

The format of the StringToList method is:

            char **StringToList(const char *text)

A description of each parameter follows:

list:

  Method StringToList returns the string list unless an error occurs, otherwise NULL.

text:

  Specifies the string to segment into a list.

## Strip

Method Strip strips the whitespace from the beginning and end of a string of characters.

The format of the Strip method is:

            void Strip(char *data)

A description of each parameter follows:

data:

  Specifies an array of characters.

## SystemCommand

Method SystemCommand executes the specified command and waits until it terminates. The returned value is the exit status of the command.

The format of the SystemCommand method is:

            int SystemCommand(const unsigned int verbose,const char *command)

A description of each parameter follows:

status:

  Method SystemCommand returns False if the command is executed successfully.

verbose:

  An unsigned integer other than 0 prints the executed command before it is invoked.

command:

  This string is the command to execute.

## TemporaryFilename

Method TemporaryFilename replaces the contents of the string pointed to in their filenames.

The format of the TemporaryFilename method is:

            void TemporaryFilename(char *filename)

A description of each parameter follows.

filename:

  Specifies a pointer to an array of characters. The unique file name is returned in this array.

## TranslateText

Method TranslateText replaces any embedded formatting characters with the appropriate image attribute and returns the translated text.

The format of the TranslateText method is:

        char *TranslateText(const ImageInfo *image_info,const Image *image,
          const char *formatted_text)

A description of each parameter follows:

translated_text:

  Method TranslateText returns the translated text string.

image_info:

  The address of a structure of type ImageInfo.

image:

  The address of a structure of type Image.

formatted_text:

  The address of a character string containing the embedded formatting characters.

## WriteByte

Method WriteByte write an integer to a file. It returns the number of bytes written (either 0 or 1);

The format of the WriteByte method is:

            unsigned long WriteByte(Image *image,const char value)

A description of each parameter follows.

count:

  Method WriteByte returns the number of bytes written.

image:

  The address of a structure of type Image.

value:

  Specifies the value to write.