Jump to content

[SOLVED] Resizing using imagecopyresampled()


whiteboikyle

Recommended Posts

here is my out come

testy.php?id=155&img=sig_gen.png

 

Here is the code

<?php
error_reporting(E_ALL); 
include("config.php");
if(isset($_GET['id'])){
if(isset($_GET['img'])){
	if(ctype_digit($_GET['id'])){
		$query = $config->query("SELECT * FROM `members` WHERE `id` = '".mysql_escape_string($_GET['id'])."'");
		if(mysql_num_rows($query) == 1){
			$row = mysql_fetch_array($query);
			$userpic = $row['picture'];
			$rank = $row['rank'];
			$rank = "images/".$rank.".jpg";
			$rank = imagecreatefromjpeg($rank);
			$result7 = $config->query("SELECT * FROM `games` WHERE ID = '".$row['game']."'");
			$row2 = mysql_fetch_array($result7);
			$explode = explode(".", $row2['image']);
			if(in_array("jpg", $explode)){
				$game = imagecreatefromjpeg($row2['image']);
			}
			elseif(in_array("png", $explode)){
				$game = imagecreatefrompng($row2['image']);
			}
			elseif(in_array("gif", $explode)){
				$game = imagecreatefromgif($row2['image']);			
			}
			else{
				die("The main game is not a png/jpg/gif!");
			}
			$userimage = imagecreatefromjpeg("http://clanan.net/image.php?memberpic=".mysql_escape_string($_GET['id']));

			$im = imagecreatefrompng("images/".$_GET['img']);
			//image.php?memberpic=".$_GET['id'
			if(!$im)
			{
				die("");
			}
			$font = "arial.ttf";
			$yellow = imagecolorallocate($im, 255, 255, 0);
			$black = imagecolorallocate($im, 0, 0, 0);
			$white = imagecolorallocate($im, 255, 255, 255);
			imagettftext($im, 10, 0, 165, 30, $white, $font, "Name: ".$row['username']);
			imagettftext($im, 10, 0, 165, 55, $white, $font, "Recruits: ".$row['recruits']);
			imagettftext($im, 10, 0, 165, 80, $white, $font, "Days In Clan: ".finddsl($row['joined']));
			imagettftext($im, 10, 0, 165, 105, $white, $font, "AIM: ".$row['aim']);
			imagettftext($im, 10, 0, 165, 130, $white, $font, "DSL: ".finddsl($row['timestamp']));

			imagettftext($im, 10, 0, 305, 30, $white, $font, "Main Game");
			imagecopymerge($im, $game, 325, 35, 0, 0, 28, 14, 100);
			imagecopymerge($im, $rank, 15, 115, 0, 0, 130, 25, 100);
			imagecopyresampled($im, $userimage, 30, 10, 0, 0, 100, 100, 100, 100);
			//imagecopymerge($im, $userimage, 30, 10, 0, 0, 100, 100, 100);
			//imagestring($im, 3, 165, 15, "TESTING", $white);
			header('Content-type: image/png');
			imagepng($im);
			imagedestroy($im);
		}
		else{
			die("The ID you submitted came back as 0 results");
		}
	}
	else{
		die("ID must be numeric!");
	}
}
else{
	die();
}
}
else{
die();
}
?>

 

I am trying to get the picture (above the Commander) to resize to 100 by 100 pixels..

the url to the image is

http://clanan.net/image.php?memberpic=155

 

I dono why mine isn't resized

Link to comment
Share on other sites

Try this.

 

$userimage_size = getimagesize("http://clanan.net/image.php?memberpic=".mysql_escape_string($_GET['id']);

imagecopyresampled($im, $userimage, 30, 10, 0, 0, 100, 100, $userimage_size[0], $userimage_size[0]);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.