Victory Road Archive

You are viewing an archive of Victory Road.

Victory Road closed on January 8, 2018. Thank you for making us a part of your lives since 2006! Please read this thread for details if you missed it.

Technology → PHP Image List

Page 1 of 1

1. SpaceMan++ said on February 20, 2009, 09:46:28 PM (-08:00)

Zoroark
288 posts

Here is a script that I've used to put all banners to one big image.
This script put all(.png) images in a certain folder to one big image, this script uses greedy algorithm(http://en.wikipedia.org/wiki/Word_wrap#Algorithm ) of word wrapping.

Code:
#!/usr/bin/php
<?php

//please edit.
//width of the image.
$Width = 2500;
//height of the image
$Height = 2500;
//padding between all images.
$padding = 15;


$x = $padding;
$y = $padding;
$max = 0;

$image = imagecreatetruecolor($Width, $Height);
$col = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), $col);

$files = explode("\n", `ls *.png`);

foreach ($files as $file)
{
	if (file_exists($file))
	{
		$copy = imagecreatefrompng($file);
		if (!is_resource($copy))
		{
			continue;
		}
		$sx = imagesx($copy);
		$sy = imagesy($copy);
		
		if ($x + $sx > imagesx($image))
		{
			$y += $max;
			$x = $padding;
		}
		imagecopy($image, $copy, $x, $y, 0, 0, $sx, $sy);
		$x += $sx + $padding;
		if ($sy > $max)
		{
			$max = $sy + $padding;
		}
		imagedestroy($copy);
	}
}

imagepng($image);
imagedestroy($image);
?>
It must be run on a Linux server such as freehostia and buizel.net
To use the script, edit the first few lines to change the options.
Here is something I've generated with that script:
http://spacemanplusplus.deviantart.com/ ... -113279109

Page 1 of 1

User List - Contact - Privacy Statement - Lycanroc.Net