andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Is there any limit for process?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Mask
View previous topic :: View next topic  
Author Message
Mobilos
Guest





PostPosted: Fri Dec 15, 2006 3:26 am    Post subject: Is there any limit for process? Reply with quote

Hi...

I have try using the class. My oppinion... its great!!!!

I am found it when I am needed learning GD and for notice I am new on it.

I have applied it at my experiment. The idea is I have image that will be masking, before doing the masking I can determine starting coordinate position where the masking will be doing (This is still use masking class too but the masking template is only patern path).

In my localhost server (php ver 4.4.2, GD ver 2.0.28 ) the result is great and successful for 4 different masking shape but when I try it on live web server (php ver 4.3.11, GD ver 2.0.28 ) 3 from 4 shape process is not successfull, no image resulted.

Because above problem I have continue experiment for problem solving.
For 1st live site test I am using image source with dimension 300x500 pixel and same too for the masking template (contain path patern).

By making the masking canvas dimension more small than the image dimension or make some of shape patern out of template dimension, it can make the masking work for 2 from 3 patern. I cannot make the last one work. Sad

This is the code for my experiment :
Code:

<?
require_once ( 'db.php');
$db = new db;
$connections = $db->connect();

// Tabel & data need
$table = "pieces";
$value = "pieces_".$no."_template, pieces_".$no."_img_src, pieces_".$no."_mask, pieces_".$no."_coor";

// Template select & define output file name
$file = "position.jpg";
$prevfile = "prevposition.jpg";
$prefile = "preposition.jpg";
//$prefile = "preposition.gif";

$sql_preview = "SELECT ".$value." FROM ".$table." WHERE test_id=".$id;
$result_preview = $db->query($sql_preview);
$preview = $db->fetch_array($result_preview);

if ($preview["pieces_".$no."_template"] != ""){
   $temp = $preview["pieces_".$no."_template"]; // source of original patern path masking template.
   }
if ($preview["pieces_".$no."_img_src"] != ""){
   $image = "../picture_library/".$id."/".$preview["pieces_".$no."_img_src"]; // source of image.
   $pic = imagecreatefromjpeg($image);
   }

$qual = 100; // zero (worst) to 100 (best)
$template = "template/".$temp; // jpg/gif filename

// Picture merge for making new patern path masking template.
   if ($preview["pieces_".$no."_template"] != ""){   
        if ($preview["pieces_".$no."_img_src"] != ""){   
            list($width_temp, $height_temp) = getimagesize($template);
            list($width, $height) = getimagesize($image);
          if ($width > $height) {
          $percent = $height_temp/ $height;
          $newwidth = $width * $percent;
          $newheight = $height * $percent;
          } else {
          $percent = $height_temp/ $height;
          //$percent = $width_temp/ $width;
          $newwidth = $width * $percent;
          $newheight = $height * $percent;
          }

          $thumb = imagecreatetruecolor($newwidth, $newheight);
          imagecopyresized($thumb, $pic, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
          imagejpeg($thumb,'../picture_library/'.$id.'/'.$file, $qual);
          imagedestroy($pic);
          imagedestroy($thumb);
   
       //get coordinate image merge
       $use = "../picture_library/".$id."/".$file ;
       list($width_canvas, $height_canvas) = getimagesize($use);
       $mask = "template/masks/round_".$preview["pieces_".$no."_mask"];
       list($width, $height) = getimagesize($mask);
      
          $im = imagecreate($width_canvas, $height_canvas);
       $bg = imagecolorallocate($im, 255, 255, 255);
       $pic = imagecreatefromjpeg($mask);
       //$pic = imagecreatefromgif($mask);
      
       $placement = $preview["pieces_".$no."_coor"];
       $val = explode(",", $placement);
       $x = $val[0];
       $y = $val[1];

       imagecopy($im, $pic, $x, $y, 0, 0, $width, $height);
          }
        }

//imagegif($im,'../picture_library/'.$id.'/'.$prefile, $qual);
imagejpeg($im,'../picture_library/'.$id.'/'.$prefile, $qual);
imagedestroy($pic);
imagedestroy($im);

// Masking image

require ( 'lib/class.imagemask.php');

      if ($preview["pieces_".$no."_img_src"] != ""){   
    $masking = new imageMask('ffffff');
    $masking->setDebugging(true);
    $masking->maskOption(mdCENTRE);
    if ($masking->loadImage('../picture_library/'.$id.'/'.$file))
    {
      if ($masking->applyMask('../picture_library/'.$id.'/'.$prefile))
      {
            $masking->saveImage('../picture_library/'.$id.'/'.$file);
        }
    }
      }

// preparing preview (thumb) image
$show = "../picture_library/".$id."/".$file ; // jpg filename
$percent = 0.4;
 
//Get new sizes
list($width, $height) = getimagesize($show);
$newwidth = $width * $percent;
$newheight = $height * $percent;

$img = imagecreatefromjpeg($show);
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb,'../picture_library/'.$id.'/'.$prevfile, $qual);
imagedestroy($img);
imagedestroy($thumb);

$db->close();
?>


Is there any one can tell me what make this problem and maybe the solution too? Are the problem in supplied image, masking template or processing timeout???

Please help me for solving the problem.

Thanks.
Back to top
Mobilos
Guest





PostPosted: Fri Dec 15, 2006 11:04 pm    Post subject: Reply with quote

Idea Today I have test again the page at different server......
the result..... now the class can work well Smile

I still have question about using the class, is different server and php version can give effect for the class result?

In unsucessful process yesterday I am using server with php version 4.3.11, server API: Apache 2.0 Handler, today I am using server with php version 4.4.3, server API: CGI (Apache 1.3.37), my localhost using server with php version 4.4.2, server API: Apache 2.0 Handler (Apache ver. 2.0.58 ).


Thanks
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Image Mask All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group