title: image resize using php image magician
body: <p>i am trying to display an uploaded image along with text watermark in a different size using  php-image-magician without saving the image.</p>
  
  <p>here are the codes : </p>
  
  <pre><code>&lt;?php
  
  $errors = array();
  
  function mimeValidator($imagefile)
  {
  $imageInfo = getimagesize($imagefile);
  $allowedMimes = array('image/jpg', 'image/jpeg', 'image/png');
  
  if(!in_array($imageInfo['mime'], $allowedMimes))
  $errors[] = "Only jpg and png images are supported";
  }
  
  function renderImage($imageSource, $watermark, $fontSize, $font)
  {
  $imageInfo = getimagesize($imageSource);
  list($width,$height) = getimagesize($imageSource);
  
  if($imageInfo['mime'] == 'image/jpg' || $imageInfo['mime'] == 'image/jpeg')
  $imageSource = imagecreatefromjpeg($imageSource);
  elseif($imageInfo['mime'] == 'image/png')
  $imageSource = imagecreatefrompng($imageSource);
  
  $image = imagecreatetruecolor($width, $height);
  $blue = imagecolorallocate($image, 79, 166, 185);
  $text = imagettftext($imageSource, $fontSize, 0, 20, ($height-20), $blue, $font,      $watermark);
  
  ob_start();
  imagejpeg($imageSource);
  $image = ob_get_contents();
  ob_end_clean();
  
  return base64_encode($image);
  }
  
  ?&gt;&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
  image Watermark and resize
  &lt;/title&gt;
  
  &lt;style type="text/css"&gt;
  body{ width:800px; margin: 15px auto; padding:0px; font-family: arial}    
  
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="imageUpload" id="imageUpload" method="post" enctype="multipart/form-data" &gt;
  &lt;fieldset&gt;
  &lt;legend&gt;Image text watermark&lt;/legend&gt;
  Text: &lt;input type="text" name="text" id="text"/&gt;&lt;br /&gt;
  Image: &lt;input type="file" name="image" id="image"/&gt;&lt;br /&gt;
  &lt;input type="submit" name="submit" id="createmark" value="Submit" /&gt;
  &lt;/fieldset&gt;   
  &lt;?php
  
  if(isset($_POST['submit']))
  {
  if($_POST['text'] == '')
  $errors[] = "Text is too short";
  
  if($_FILES['image']['tmp_name'] == '')
  $errors[] = "Please upload a image";
  else
  mimeValidator($_FILES['image']['tmp_name']);
  
  if(count($errors) == 0)
                  {
  include('php-image-magician/php_image_magician.php');
  
  $magicianObj = new imageLib($_FILES["image"]["tmp_name"]);
  $magicianObj -&gt; resizeImage(100, 200);
  $magicianObj -&gt; saveImage($imagename);
  echo "&lt;img src=\"data:image/gif;base64," . renderImage($_FILES["image"]["tmp_name"],  $_POST['text'], 30, "./arial.ttf") . "\" /&gt;";
  }
  else
  {
  echo "&lt;ul&gt;";
  
  foreach($errors as $error)
  echo "&lt;li&gt;{$error}&lt;/li&gt;";
  
  echo "&lt;/ul&gt;";
  }
  
  }
  ?&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>i am getting an error "file C:\xampp\tmp\php9E3D.tmp is missing or invalid"
  i am a newbee in this. please help me.</p>