gisinternals / buildsystem

Build system on www.gisinternals.com
MIT License
35 stars 10 forks source link

mapserver with apache24 and mode=map serves a broken image #193

Closed amr66 closed 2 years ago

amr66 commented 2 years ago

I run gisinternals mapserver with an Apache24 under win10. When I request a map with a html template and mode=browse everything works fine but if I try to use mode=map I get an error in my browser (Firefox): 'Die Grafik "http://localhost:8008/ms-bin/mapserv.exe?map=/gims/mapserver/test/regio_tr.map&mode=map" kann nicht angezeigt werden, weil sie Fehler enthält.' (The Image ... can't be displayed, because it contains errors). I don't see any errors in the Apache log files nor in the mapserver debug logs. I'm not completly sure if this error belongs to mapserver or to the apache config.

szekerest commented 2 years ago

@amr66 Could you download the resulting image and attach that to this ticket?

amr66 commented 2 years ago

@szekerest thank you, here it is: mapserv exe

szekerest commented 2 years ago

@amr66 pngcheck says that the file is corrupted by text conversion. I'm not sure however it has happened during the png creation or when it was saved to the file. Could you provide some test data to reproduce this problem? If you open a gisinternals command prompt and run mapserv from the command line, does it provied correct result? Something like:

mapserv -nh "QUERY_STRING=map=/gims/mapserver/test/regio_tr.map&mode=map" > sample.png

amr66 commented 2 years ago

@szekerest sure, this is the output file: sample

amr66 commented 2 years ago

Another simple example is the "Hello World"-map file, ignore the template, it is called with mode=map of course

MAP
   NAME HELLO 
   STATUS ON 
   EXTENT 0 0 4000 3000 
   SIZE 400 300 
   IMAGECOLOR 180 60 255 
WEB
   IMAGEPATH "/gims/mapserver/test/ms_tmp/" 
   IMAGEURL "/test/ms_tmp/" 
   TEMPLATE "/gims/mapserver/test/hw.htm"
END 
LAYER
     STATUS default
     TYPE point
     FEATURE
          POINTS  2000.00 1500.00 END
          TEXT "Hello World. Mapserver rocks."
     END # end feature
     CLASS
          STYLE
               COLOR 255 0 0
          END
          LABEL
               TYPE bitmap
          END
     END
END 
END
geographika commented 2 years ago

@amr66 - any difference if you add a specific IMAGETYPE of png to the Mapfile?

amr66 commented 2 years ago

Good Idea!

OUTPUTFORMAT
  NAME "jpeg"
  DRIVER AGG/JPEG
  MIMETYPE "image/jpeg"
  IMAGEMODE RGB
  EXTENSION "jpg"
END

It shows the image, but it looks weird mapserv exe .

szekerest commented 2 years ago

Checked the wrong output and it seems that the stdout is not being switched to binary mode so extra 0x0D bytes are inserted into the image. Looks like we need to patch libfcgi to get it working as per: https://github.com/MapServer/MapServer/issues/1153

I'll apply that fix and trigger a new build with that.

amr66 commented 2 years ago

I can confirm, that replacing libfcgi.dll from an osgeo4w install with same 64-bit MSVC 2019 (in my case) works.

geographika commented 2 years ago

@szekerest - could this also be the cause of https://github.com/MapServer/MapServer/issues/6459 ?

szekerest commented 2 years ago

@geographika yes, definitely

szekerest commented 2 years ago

Recompiled the release versions https://www.gisinternals.com/release.php It seems that the problem was fixed.

amr66 commented 2 years ago

Thank you for your quick fix. It works!

szekerest commented 2 years ago

Thank you, closing this