*/ // Return source code if(isset($_GET['source'])) { header("Content-Type: text/plain"); die(file_get_contents(basename($_SERVER['PHP_SELF']))); } function convert() { $files = $_FILES['files']; if($files['error'][0]) return "You must upload at least one image and GRIT file"; for($i = 0; $i < count($files['name']); $i++) { if(!empty($files['tmp_name'][$i]) && $files['error'][$i] == 0) { if($files['type'][$i] == 'image/png' || $files['type'][$i] == 'image/bmp') { $grit = array_search(preg_replace('/\.(?:png|bmp)/', '.grit', $files['name'][$i]), $files['name']); if($grit !== false) { if(move_uploaded_file($files['tmp_name'][$i], 'temp/' . $files['name'][$i]) && move_uploaded_file($files['tmp_name'][$grit], 'temp/' . $files['name'][$grit])) { $output = null; $ret = null; exec("grit 'temp/{$files['name'][$i]}' -ftr -fh! -o'temp/{$files['name'][$i]}'", $output, $ret); if($ret != 0) return "grit conversion failed on image {$files['name'][$i]}"; } else { return "Unable to upload image {$files['name'][$i]}, please contact the webmaster"; } } else { return "Image {$files['name'][$i]} is missing a .grit file"; } } else if($files['type'][$i] == 'application/octet-stream' && preg_match('/\.grit$/', $files['name'][$i])) { if(array_search(preg_replace('/\.grit/', '.png', $files['name'][$i]), $files['name']) === false && array_search(preg_replace('/\.grit/', '.bmp', $files['name'][$i]), $files['name']) === false) { return "GRIT file {$files['name'][$i]} is missing an image"; } } else { return "Files must be PNG/BMP images with matching GRIT files"; } } } } function cleanup() { foreach($_FILES['files']['tmp_name'] as $file) { @unlink($file); } foreach($_FILES['files']['name'] as $file) { @unlink('temp/' . $file); @unlink('temp/' . preg_replace('/\.(?:png|bmp)/', '.grf', $file)); } } // Ceanup old files $dir = opendir('temp'); if ($dir) { while (($file = readdir($dir)) !== false) { @unlink('temp/' . $file); } } closedir($dir); if($_POST['submit'] == 'Convert') { $err = convert(); if(empty($err)) { $output = null; $ret = null; $zipName = time() . '.zip'; exec("cd temp && 7z a $zipName *.grf", $output, $ret); if($ret == 0) { header('Content-Type: application/zip'); header('Content-Transfer-Encoding: Binary'); header('Content-Disposition: attachment; filename="converted.zip"'); readfile("temp/$zipName"); cleanup(); exit(); } } cleanup(); } ?> GRIT | ピケ.コム
Online GRIT converter
$err"; ?>

You must upload one .png or .bmp image and one .grit file for each image you want converted. Uploading multiple pairs of images and GRIT files at a time is supported.

A ZIP file with your converted GRF files inside will then be downloaded.

If you graphics come out corrupted it's probably because the palettes are somehow wrong. Check that there aren't more colors in the image than the -pn in your GRIT file. (ex. -pn32 is 32 colors) It may work better to upload a non-paletted image depending on the image.

[back] [source]