[mapserver-users] PHP $imgObj->saveImage(null) sends headers

Pavel Iacovlev iacovlev.pavel at gmail.com
Mon Apr 5 13:34:16 EDT 2010


1) Your php code is not correct I think, ob_get_clean  just cleans the
output and does not return the captured content.
2) Try with no framework, maybe it sends some headers before you run your code.

This works for me in Zend Framework in MVC mode, should work for symfony too.
ob_start();
$image->saveimage('');
$image = imagecreatefromstring(ob_get_contents());
ob_end_clean();
imagepng($image);

2010/4/5 Miloslav Kmeť <miloslav.kmet at gmail.com>:
> Hi. I am trying to use php_mapscript in MVC framework (symfony) and I want to
> catch the output of $imgObje->saveImage(null); for the later processing, eg:
> using the builtin cache mechanism instead of directly writing the file to the
> cache.
>
> My code very simplified looks like:
>
> ob_start();                            // start output buffering
> $imgObj->saveImage(null);  // print output to std
> $image = ob_get_clean();   // get the buffer and clen it
>
> header('Content-type: image/jpeg'); // setting the header
> echo $image; // printing the image
>
> At the header line I got an header already sended error, even no output will
> be brinted before.
>
> I looked into php_mapscript.c and I found that in the saveImage function there
> is php_header(TSRMLS_C); As I do not know the PHP internals, i do not know
> what that call is doing, but when I removed it out, and recompiled the
> extension,
>
> Now output buffering is working correctly.
>
> What is the function doing? Should it be replaced in the main development?
>
> Thanks
> --
> Miloslav Kmeť
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>



-- 
http://iap.md, The future is open


More information about the mapserver-users mailing list