• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Resize Image on Upload

WebWatcher

New Member
Hey
Does anybody now of a way or a script that i could use when uploading picture files which would load the image and save them in the following way:

1 As a thumbnail i.e 70X70

2 As a image used in flash i.e 100x100

3 as in its original form

Thanks in advance
 
PHP:
<?php
function resize( $gd, $width, $height )
{
	if( ( $resize = imagecreatetruecolor( $width, $height ) ) )
	{
		if( imagecopyresampled( $resize, $gd, 0, 0, 0, 0, $width, $height, imagesx( $gd ), imagesy( $gd ) ) )
		{
			return $resize ;
		}
	}
}

if( ( $gd = imagecreatefromgif( 'image.gif' ) ) )
{	
	if( ( $thumb = resize( $gd, 70, 70 ) ) )
	{
		imagepng( $thumb, 'thumb.png' );
	}

	if( ( $flash = resize( $gd, 100, 100 ) ) )
	{
		
		imagepng( $flash, 'flash.png' );
	}

	imagedestroy( $gd );
	imagedestroy( $thumb );
	imagedestroy( $flash );
}
?>
 
Last edited:
Back
Top