{
    $file_open_type = 'w';
    if ($binary_output) {
        $file_open_type = 'wb';
    }
    $stream = fopen((string) $filename, $file_open_type);
    if (false === $stream) {
        return false;
    }
    write_mandelbrot_to_stream((int) $w, (int) $h, $stream, (bool) $binary_output);
    fclose($stream);
    return true;
}
function treffynnon_mandelbrot_to_mem($w, $h, $binary_output)
{
    $file_open_type = 'w+';
    if ($binary_output) {
        $file_open_type = 'w+b';
    }
    $stream = fopen('php://memory', $file_open_type);
    if (false === $stream) {
        return '';
    }
    write_mandelbrot_to_stream((int) $w, (int) $h, $stream, (bool) $binary_output);
    rewind($stream);
    $ret = stream_get_contents($stream);
    fclose($stream);
    return $ret;
}
echo treffynnon_mandelbrot_to_mem((int) $_GET['seed'], (int) $_GET['seed'], false);
                $byte_acc = 0;
            }
        } else {
            echo "\n";
        }
    }
    return true;
}
function treffynnon_mandelbrot_to_file($filename, $w, $h, $binary_output)
{
    $file_open_type = 'w';
    if ($binary_output) {
        $file_open_type = 'wb';
    }
    $stream = fopen((string) $filename, $file_open_type);
    if (false === $stream) {
        return false;
    }
    ob_start();
    write_mandelbrot_to_stream((int) $w, (int) $h, (bool) $binary_output);
    fwrite($stream, ob_get_clean());
    return true;
}
function treffynnon_mandelbrot_to_mem($w, $h, $binary_output)
{
    ob_start();
    write_mandelbrot_to_stream((int) $w, (int) $h, (bool) $binary_output);
    return ob_get_clean();
}
echo treffynnon_mandelbrot_to_mem((int) $argv[1], (int) $argv[1], false);