4utility - ImageMagick Utility Methods9/


NAME



%utility - ImageMagick Utility Methods




(

SYNOPSIS



Jchar * AllocateString( const char *source );

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

&BaseFilename( name );

cunsigned int CloneString( char ** destination, const char *source );

>unicode= ConvertTextToUnicode( text, count );

,ExpandFilename( filename );

7status= ExpandFilenames( argc, argv );

Mvoid FormatString( char *string, const char *format, ... );

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

7GlobExpression( expression, pattern );

Qunsigned int IsAccessible( const char *filename );

Punsigned int IsDirectory( const char *filename );

Qint Latin1Compare( const char *p, const char *q );

@filelist= ListColors( pattern, number_colors );

Kfilelist= ListFiles( directory, pattern, number_entries );

Evoid LocaleFilename( char *filename );

Hint MultilineCensus( const char *label );

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

Pvoid Destroy PostscriptGeometry( char *geometry );

Gchar * SetClientName( const char *name );

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

Hchar ** StringToList( const char *text );

8void Strip( char *data );

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

Hvoid TemporaryFilename( char *filename );

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




B

FUNCTION DESCRIPTIONS






4

AllocateString



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

+The format of the AllocateString method is:F

char *AllocateString ( const char *source );


=A description of each parameter follows:

B

allocated_string:


:Method AllocateString returns a copy of the source string.#

source:


(A character string.






:

AppendImageFormat



JMethod 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:X

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


=A description of each parameter follows.

#

format:


HSpecifies a pointer to an array of characters. This is the format of theimage.%

filename:


FSpecifies a pointer to an array of characters. The unique file name isreturned in this array.






0

BaseFilename



GMethod BaseFilename removes the path name component and any extensions.

+The format of the BaseFilename function is:0

BaseFilename ( name );


=A description of each parameter follows:

!

name:


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






.

CloneString



IMethod 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:


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

destination:


5A pointer to a character string.#

source:


(A character string.






@

ConvertTextToUnicode



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

3The format of the ConvertTextToUnicode function is:G

unicode=ConvertTextToUnicode ( text, count );


=A description of each parameter follows:

$

unicode:


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

text:


KSpecifies a pointer to a character array that contains the text to convert."

count:


3The number of characters that were translated from JASCII to Unicode is returned in this unsigned integerpointer.






4

ExpandFilename



0Method ExpandFilename expands '~' in a filename.

-The format of the ExpandFilename function is:6

ExpandFilename ( filename );


=A description of each parameter follows:

%

filename:


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






6

ExpandFilenames



JMethod ExpandFilenames checks each argument of the command line vector andFexpands 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:


JSpecifies a pointer to an integer describing the number of elements in theargument vector.!

argv:


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






0

FormatString



HMethod FormatString prints formatted output of a variable argument list.

)The format of the FormatString method is:V

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


=A description of each parameter follows.

#

string:


JMethod FormatString returns the formatted string in this character buffer.#

format:


GA string describing the format to use to write theremaining arguments.






.

GetGeometry



IMethod GetGeometry parses a geometry specification and returns the width,Jheight, x, and y values. It also returns flags that indicates which of theIfour values (width, height, xoffset, yoffset) were located in the string,9and 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:


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

image_geometry:


ESpecifies a character string representing the geometry specification.

x,y:


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

width,height:


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






4

GlobExpression



IMethod GlobExpression returns True if the expression matches the pattern.

-The format of the GlobExpression function is:A

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.






0

IsAccessible



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

)The format of the IsAccessible method is:M

unsigned int IsAccessible ( const char *filename );


=A description of each parameter follows.

#

status:


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

filename:


FSpecifies a pointer to an array of characters. The unique file name isreturned in this array.






.

IsDirectory



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

)The format of the IsAccessible method is:L

unsigned int IsDirectory ( const char *filename );


=A description of each parameter follows.

#

status:


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

filename:


FSpecifies a pointer to an array of characters. The unique file name isreturned in this array.






2

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:M

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


=A description of each parameter follows:



p:


IA pointer to the string to convert to Latin1 string.

q:


IA pointer to the string to convert to Latin1 string.






,

ListColors



Method ListColors reads the IX 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:I

filelist=ListColors ( pattern, number_colors );


=A description of each parameter follows:

%

filelist:


hMethod 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:


6This integer returns the number of colors in the list.






*

ListFiles



DMethod ListFiles reads the directory specified and returns a list ofJfilenames contained in the directory sorted in ascending alphabetic order.

(The format of the ListFiles function is:T

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:


ASpecifies a pointer to a text string containing a directory name.$

pattern:


:Specifies a pointer to a text string containing a pattern.+

number_entries:


9This integer returns the number of filenames in the list.






4

LocaleFilename



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

+The format of the LocaleFilename method is:A

void LocaleFilename ( char *filename );


=A description of each parameter follows.

%

filename:


FSpecifies a pointer to an array of characters. The unique file name isreturned in this array.






6

MultilineCensus



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

+The format of the MultilineCenus method is:D

int MultilineCensus ( const char *label );


=A description of each parameter follows.

"

label:


#This character string is the label.






2

ParseGeometry



IMethod ParseImageGeometry parses a geometry specification and returns theJwidth, height, x, and y values. It also returns flags that indicates whichHof the four values (width, height, xoffset, yoffset) were located in theAstring, 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:


GMethod ParseImageGeometry returns a bitmask that indicates which of the0four values were located in the geometry string.+

image_geometry:


ESpecifies a character string representing the geometry specification.

x,y:


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

width,height:


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






<

PostscriptGeometry



IMethod PostscriptGeometry replaces any page mneumonic with the equivalentsize in picas.

/The format of the PostscriptGeometry method is:L

void DestroyPostscriptGeometry ( char *geometry );


=A description of each parameter follows.

!

page:


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






2

SetClientName



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

*The format of the SetClientName method is:C

char *SetClientName ( const char *name );


=A description of each parameter follows:

(

client_name:


5Method SetClientName returns the current client name.#

status:


Specifies the new client name.






0

StringToArgv



GMethod StringToArgv converts a text string into command line arguments.

)The format of the StringToArgv method is:N

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


=A description of each parameter follows:

!

argv:


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

text:


,Specifies the string to segment into a list.!

argc:


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






0

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 dHEX characters if any control characters are discovered within the text string.

)The format of the StringToList method is:C

char **StringToList ( const char *text );


=A description of each parameter follows:

!

list:


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

text:


,Specifies the string to segment into a list.






"

Strip



IMethod Strip strips the whitespace from the beginning and end of a stringof characters.

"The format of the Strip method is:4

void Strip ( char *data );


=A description of each parameter follows:

!

data:


!Specifies an array of characters.






2

SystemCommand



FMethod SystemCommand executes the specified command and waits until itAterminates. 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:


KMethod SystemCommand returns False if the command is executed successfully.$

verbose:


IAn unsigned integer other than 0 prints the executed command before it isinvoked.$

command:


&This string is the command to execute.






:

TemporaryFilename



JMethod TemporaryFilename replaces the contents of the string pointed to intheir filenames.

.The format of the TemporaryFilename method is:D

void TemporaryFilename ( char *filename );


=A description of each parameter follows.

%

filename:


FSpecifies a pointer to an array of characters. The unique file name isreturned in this array.






2

TranslateText



IMethod 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:


8Method 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:


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