Image editing using ImageMagick PHP library -
i developing image editor, write text on images on position x,y, need draw white image on image called white out. white image drawn @ position cord x, cord y , dynamic size of image width, height. write code not getting image on right coordinates , height width of image. here image rendering function.
$image = new imagick('image.jpg'); $diagnose=$this->input->post('diagnoses'); $fontsize=$this->input->post('fontsize'); $fontstyle=$this->input->post('fontstyle'); $cordx = $this->input->post('posx'); $cordy = $this->input->post('posy'); $font_size = 20; // watermark text //$diagnose = "hello world.{newline}it's beautiful day."; $textlinesarray = explode("{newline}",$diagnose); // create new drawing palette $draw = new imagickdraw(); // set font properties $draw->setfont('arial'); $draw->setfontsize($font_size); $draw->setfillcolor('black'); // position text @ bottom-right of image $draw->setgravity(imagick::gravity_northwest); $i = 0; foreach ($textlinesarray $index => $text) { $newy = ($i * $font_size) + $cordy; //echo $newy . "</br>"; //echo $text; // draw text on image $image->annotateimage($draw, $cordx, $newy,0, $text); $i++; } $draw->setfillcolor('magenta'); // set colors use fill , outline $draw->setstrokecolor( new imagickpixel( 'cyan' ) ); $draw->setstrokewidth(2); $draw->rectangle($cordx, $cordy, 200, 300); // draw rectangle $image->drawimage( $draw ); // set output image format $image->setimageformat('png'); // output new image header('content-type: image/png'); echo $image;
here output, need color box dynamic width height , position
Comments
Post a Comment