Server Help

Misc User Apps - PHP: LVL to PNG/JPG

CypherJF - Wed Jun 01, 2005 2:27 am
Post subject: PHP: LVL to PNG/JPG
Quote:
File: lvl2img.php
Creator: CypherJF (ssCypherJF@yahoo.com)
URL: http://cypherjf.sscentral.com
Version: 1.1
Source: Released.

* This PHP (www.php.net) script will take a Subspace LVL mapfile and create a PNG, or JPG output.

* This source-code was originally designed to be closed-source and therefore includes a Copyright notice on all image outputs. If you must remove it, so be it - but keep the header of this document in-tact.

* This script was -never- meant to be the most efficient PHP script known to man, but it completed the task I needed to accomplish. See the usage notes below, Enjoy.

Code: Show/Hide
Usage:
lvl2img.php?file=mapname[&width=[#]][&height=[#]][&grayscale=[#]]
-- NOTE(s)--
  * Must specify a default map file (with the extention .lvl)
  : file=<mapname>
     : do not include ".lvl"
     : will use default map, if this arguement (or file) does not exist.
     : must reside in the same directory as the script.
     : NOTE: I believe, PHP ignores variables that begin with # in the $_GET[] field.
  : width=<number>
     : * optional*
     : default: 1024
  : height=<number>
     : * optional *
     : default: 1024
  : grayscale=<#>
     : 0 (default) no; otherwise, 1.


Final Note: If you see a message that states 'Invalid Map Data. Checksum != 0.' This means that the map, or LVL, file that you tried to use appears to be corrupted and can not be deconverted.

Changes
Version 1.1 - DEFAULT_MAP arguement logic fixed by MMaverick.
- Changed a lot of " to '.
- Verified script w/ E_ALL.
. Only 1 issue left "Warning: imagecolorsforindex(): Color index # out of range in <file>"
- Added comments.

Version 1.0 - Initial.


Requires that the PHP Extension php_gd2.dll be enabled in your php.ini.
Maverick - Wed Jun 01, 2005 5:26 am
Post subject:
icon_eek.gif That's awesome biggrin.gif
very nice

I tried it on http://www.17thparallel.com/mav only it gave the same error over and over.

http://www.17thparallel.com/mav/lvl2img.php?file=17thmainmap
Quote:
Missing Default Map: omega1.lvl

Am I doing something wrong here?
Maverick - Wed Jun 01, 2005 5:38 am
Post subject:
FIXED:

Please replace:
Code: Show/Hide
$map_name = $_GET["file"].".lvl";
if (!file_exists(DEFAULT_MAPNAME))
  die("Missing Default Map: <i>".DEFAULT_MAPNAME."</i>");

if (!file_exists($map_name))
  $map_name = DEFAULT_MAPNAME;


with:
Code: Show/Hide
$map_name = $_GET["file"].".lvl";
if (!file_exists($map_name)) {
  $map_name = DEFAULT_MAPNAME;
   if (!file_exists(DEFAULT_MAPNAME))
     die("Missing Default Map: <i>".DEFAULT_MAPNAME."</i>");
}

Solo Ace - Wed Jun 01, 2005 5:48 am
Post subject:
I think Dust made this once too, anyway, good job.

I don't like your double quotes though, but I don't want to be bitchy. tongue.gif
CypherJF - Wed Jun 01, 2005 12:43 pm
Post subject:
Okay, I added the 'patch' from MMaverick in 1.1. I also used report E_ALL for testing out where things should be 'fixed'. There was only 1 warning remaining when using greyscale, but that doesn't bother me. icon_smile.gif I also moved everything from raw $_GET[] to $_CLEAN[] - you'll see what I mean if you can read PHP. icon_smile.gif Also added a few comments here and there.

Enjoy.
D1st0rt - Wed Jun 01, 2005 3:07 pm
Post subject:
Does it do the palette index stuff like FACTS?
CypherJF - Wed Jun 01, 2005 3:09 pm
Post subject:
I doubt it does. Though I do have it use the same color value as the FACTs output - or for the most part. If you know how to do this - feel free to edit the script - and give me the code to find/replace - and I'll update it accordingly.

I bet you using the:

bool imagecolorset ( resource image, int index, int red, int green, int blue)

You could be able to setup the palette accordingly...
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group