Jump to content

Recommended Posts

Im pretty much a complete noob with GD. Im trying to make a script that will multiple images from a database over a base image. heres the script.

 

<?php
  //generates pets image
  header ("Content-type: image/jpeg"); 

$roeid = $_GET['id'];

$query = mysql_query("SELECT t.image FROM roe r LEFT JOIN roetypes t ON ( r.type = t.id ) WHERE r.id = $roeid") or die(mysql_error());
$roeinfo = mysql_fetch_array($query);
$baseimg = $roeinfo['image'];
  //base image
  $system=explode('.',$baseimg);
if (preg_match('/jpg|jpeg/',$system[1])){
	$background = imagecreatefromjpeg("images/$baseimg"); 
}
if (preg_match('/png/',$system[1])){
	$background = imagecreatefrompng("images/$baseimg"); 
}
  //get clothing
  
  $sql = "SELECT c.image FROM roewearing w
	LEFT JOIN roeclothes c ON ( w.clothe = c.id )
	WHERE w.roeid = $roeid
	ORDER BY w.layer DESC";
  $query = mysql_query($sql) or die(mysql_error());

while($array = mysql_fetch_array($query)){ //create the loop

$clotheimg = $array['image'];
  $insert = imagecreatefromjpeg("images/clothes/$clotheimg"); 

  imagecolortransparent($insert,imagecolorat($insert,0,0));

  // Get overlay image width and hight for later use

  $insert_x = imagesx($insert); 
  $insert_y = imagesy($insert); 

  imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100); //overlay the clothing to the current image
}  //end the loop

  imagejpeg($background,"",100); 

//save the image
//createthumb($background,"images/roeimages/$roeid.png",200,200);

imagedestroy($background); //clean up the image
?>

Link to comment
https://forums.phpfreaks.com/topic/73513-solved-gd-image-wont-load/
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.