Changing Image Resolution

Abe Gillespie abe.gillespie at GMAIL.COM
Wed Dec 14 06:16:28 PST 2005


I know it's impossible to change DPI on-the-fly within MapServer (it's
set at compile time).  But I want to "fake" a higher resolution image
within PHP.

Let's just use PNG as an example.

I assume there's a header in the PNG image that specifies its DPI so
this info can be used by printers, image editors, etc.  So my idea is
if I want a PNG with twice the resolution (from 72 to 144 DPI) is to
simply adjust the width & height in MapServer and then edit the PNG's
header in PHP.

So, if I have a 300x200 pixel image, but I want to increase the DPI to
144:  First I'd change MapServer width & height:

$map->setSize(600, 400);

Then I'd render the image to disk, open the file up in PHP, and change
the header with some binary file operations.

Is my thinking correct here?  If so, are there any examples of binary
file manipulation via PHP.  Are there any examples of the PNG's
header?

Thanks for the help.
-Abe



More information about the MapServer-users mailing list