Closed tbonfort closed 12 years ago
Author: sgillies@frii.com Date: 2004/02/01 - 04:03
A Perl typemap would probably use PerlIO_exportFile() but there appear to be
more issues involved (predictably) than with Python. Will leave it for the
future.
The Python typemap is simple:
// Type mapping for grabbing a FILE * from Python
%typemap(python,in) FILE * {
if (!PyFile_Check($source)) {
PyErr_SetString(PyExc_TypeError, "");
return NULL;
}
$target = PyFile_AsFile($source);
}
Author: sgillies@frii.com Date: 2004/02/02 - 05:39
I still haven't mastered GD's IOCtx API and can't burn a lot of time writing
Python _and_ Perl typemaps for it, so took the easy way out and wrote code
using the Python C API only. Will revisit this at some point if there is
enough interest from Perl users.
Perl users will benefit from two optional arguments to the imageObj constructor
which allows these use cases
$imgobj = mapscript::imageObj(100, 100); # default format
$imgobj = mapscript::imageObj(100, 100, "GD/JPEG"); # JPEG
$imgobj = mapscript::imageObj(0, 0, undef, "foo.png"); # from file
Python gets these and more. Here are examples from the unit tests:
imgobj = mapscript.imageObj(10, 10)
imgobj = mapscript.imageObj(10, 10, "GD/PNG")
imgobj = mapscript.imageObj(0, 0, None, "foo.png")
f = file("foo.png", "rb")
imgobj = mapscript.imageObj(0, 0, "GD/PNG", f) # Must specify driver
import StringIO
f = file("foo.png", "rb")
s = StringIO.StringIO(f.read()) # store imagery in memory
f.close()
imgobj = mapscript.imageObj(0, 0, "GD/PNG", s) # Must specify driver
import urllib
u = urllib.urlopen("http://host/foo.png")
imgobj = mapscript.imageObj(0, 0, "GD/PNG", u) # Must specify driver
Reporter: sgillies@frii.com Date: 2004/02/01 - 03:53