4.5.
ImageObj Class
Up one level
Constructor, members, and methods.
- Constant names and class member variable names are case-sensitive in PHP.
- Several MapScript functions (all those that access files in the back end such as ms_newMapObj(), drawMap(), etc.) will affect the value of the current working directory (CWD) in the PHP environment. This will be fixed eventually but in the meantime you should be careful about these side-effects.
Constructor:
Instances of ImageObj are always created by the map class methods.
Members:
int width (read-only)
int height (read-only)
string imagepath
string imageurl
Methods:
void free()
Destroys resources used by an image object.
int saveImage(string filename, MapObj oMap)
Writes image object to specifed filename.
Passing an empty filename sends output to stdout. In this case,
the PHP header() function should be used to set the documents's
content-type prior to calling saveImage().
The output format is the one that is currently selected in the
map file.
The second argument oMap is not manadatory. It is usful when
saving to formats like GTIFF that needs georeference informations
contained in the map file.
The function returns -1 on error. On success, it returns either 0
if writing to an external file, or the number of bytes written if
output is sent to stdout.
string saveWebImage()
Writes image to temp directory. Returns image URL.
The output format is the one that is currently selected in the
map file.
void pasteImage(imageObj srcImg, int transparentColorHex
[[, int dstX, int dstY], int angle])
Copy srcImg on top of the current imageObj.
transparentColorHex is the color (in 0xrrggbb format) from srcImg
that should be considered transparent (i.e. those pixels won't
be copied). Pass -1 if you don't want any transparent color.
If optional dstx,dsty are provided then it defines the position
where the image should be copied (dstx,dsty = top-left corner
position).
The optional angle is a value between 0 and 360 degrees to rotate
the source image counterclockwise. Note that if an angle is specified
(even if its value is zero) then the dstx and dsty coordinates
specify the CENTER of the destination area.
Note: this function works only with 8 bits GD images (PNG or GIF).