mapscript.imageObj¶
- class mapscript.imageObj(*args)¶
An image object is a wrapper for images generated by MapServer.
Attributes
format
outputFormatObj
immutable anoutputFormatObj
representing the output format of the imageheight
int immutable image height in pixels
imagepath
char immutable if image is drawn by
mapObj.draw()
this is IMAGEPATHimageurl
char immutable if image is drawn by
mapObj.draw()
this is IMAGEURLresolution
double immutable image resolution in pixels per inch
resolutionfactor
double immutable resolution factor
thisown
The membership flag
width
int immutable image width in pixels
Methods
- __init__(*args)[broncode]¶
Create a new
imageObj
instance. If filename is specified, an imageObj is created from the file and any specified width, height, and format parameters will be overridden by values of the image in filename. Otherwise, if format is specified (as anoutputFormatObj
) an imageObj is created using that format. If filename is not specified, then width and height should be specified. The default resolution is currently 72 and defined byMS_DEFAULT_RESOLUTION
- this setting is not available in MapScript.
- getBytes() gdBuffer [broncode]¶
Returns the image contents as a binary buffer. The exact form of this buffer will vary by MapScript language (e.g. a string in Python, byte[] array in Java and C#, unhandled in Perl)
- getSize() int [broncode]¶
Returns the size of the binary buffer representing the image buffer
Notitie
The getSize method is inefficient as it does a call to getBytes and then computes the size of the byte array. The byte array is then immediately discarded. In most cases it is more efficient to call getBytes directly.
- pasteImage(imageSrc: imageObj, opacity: double = 1.0, dstx: int = 0, dsty: int = 0) int [broncode]¶
Pastes another imageObj on top of this imageObj. If optional dstx,dsty are provided then they define the position where the image should be copied (dstx,dsty = top-left corner position).
- save(filename: char, map: mapObj = None) void [broncode]¶
Save image to filename. The optional map parameter must be specified if saving GeoTIFF images.
- saveWebImage() char [broncode]¶
Writes the image to temp directory. Returns the image URL.
- write(*args) int [broncode]¶
Write image data to an open file handle. Replaces the removed saveToString function. See
python/pyextend.i
for the Python specific version of this method.