PHP - Magick Wand Help
Hello,
I am in the process of making a script for a online store which automatically generates category images. The idea is a user uploads a image, and is then presented with a page in which they can crop a selection of the image to use as a category image (http://www.codeforest.net/how-to-crop-an-image-using-jquery-and-php i modified this code) once this has happened and the user presses a preview button, they are presented with a new page with a preview of the category image. Here comes my problem, the "category image" is basically the image the user uploaded scaled down to whatever size they chose on the jquery interface with a number of other layers added on top, one subtracts edges so it is a rounded shape, another adds a border and another adds a flash on which text needs to be displayed. This all works great. The problem comes when i want to add the text to the image. I am using the MagickAnnotateImage method and from what i understand the x and y co-ordinates you provide are from the top left hand corner of the picture. When i am adding the text it seems to treat the image as if it is the size of the original image the user uploaded. So for example, if the user drops an image which is the very right hand bottom corner of the image they uploaded it wont show the text because i have set the text to appear 20 pixels from the left hand corner and the crop they made probably starts 100 pixels in. I have no idea why it is treating the text addition as if the picture is still the size of the original because i have split the process up into two stages so when it gets to the point of adding the text it saves the modifactions made so far onto the filesystem and then reopens it using a new magic wand. Any ideas? below is my code, it might be easier to understand than my explantion lol. page one Code: [Select] $magick_wand=NewMagickWand(); MagickReadImage($magick_wand,"../images/" . $image_info['categories_image']); MagickCropImage($magick_wand,$_POST['w'],$_POST['h'],$_POST['x1'],$_POST['y1']); MagickResizeImage($magick_wand,'175','125',MW_HermiteFilter,1); // subtract border $magick_wand_subtract_border = NewMagickWand(); MagickReadImage($magick_wand_subtract_border,'../images/categories/_image_crop_anti_border.png'); MagickCompositeImage($magick_wand,$magick_wand_subtract_border,MW_CopyOpacityCompositeOp,0,0); // add border $magick_wand_add_border = NewMagickWand(); MagickReadImage($magick_wand_add_border,'../images/categories/_image_crop_add_border.png'); MagickCompositeImage($magick_wand,$magick_wand_add_border,MW_AtopCompositeOp ,0,0); // String length Test if(strlen($cat_name_query['categories_name'])<=100){ // add single flash $magick_wand_add_single_flash = NewMagickWand(); MagickReadImage($magick_wand_add_single_flash,'../images/categories/_image_crop_add_single_flash_border.png'); MagickCompositeImage($magick_wand,$magick_wand_add_single_flash,MW_AtopCompositeOp,0,0); } else { // add double flash $magick_wand_add_double_flash = NewMagickWand(); MagickReadImage($magick_wand_add_double_flash,'../images/categories/_image_crop_add_single_flash_border.png'); MagickCompositeImage($magick_wand,$magick_wand_add_double_flash,MW_AtopCompositeOp,0,0); } // Save image with layers on top MagickWriteImage( $magick_wand, '../images/temp_cat_preview/' . $image_info['categories_image']); page two Code: [Select] $magick_wand_new=NewMagickWand(); MagickReadImage($magick_wand_new,"../images/temp_cat_preview/" . $image_info['categories_image']); $drawing_wand=NewDrawingWand(); DrawSetFont($drawing_wand,"../usr/share/fonts/bitstream-vera/Vera.ttf"); DrawSetFontSize($drawing_wand,11); $pixel_wand=NewPixelWand(); PixelSetColor($pixel_wand,"white"); DrawSetFillColor($drawing_wand,$pixel_wand); // Finally add the text if (MagickAnnotateImage($magick_wand_new,$drawing_wand,20,20,0,$cat_name_query['categories_name'])!= 0) { header( 'Content-Type: image/jpg' ); MagickEchoImageBlob( $magick_wand_new ); } else { echo MagickGetExceptionString($magick_wand_new); } //unlink("../images/temp_cat_preview/" . $image_info['categories_image']); Similar TutorialsIm trying to get this imagemagick to work Code: [Select] echo shell_exec("/usr/bin/convert -version"); outputs: Code: [Select] Version: ImageMagick 6.4.8 2010-09-03 Q16 OpenMP http://www.imagemagick.org Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC This doesnt work (no image is output) What am i missing here? Code: [Select] shell_exec("/usr/bin/convert -compress JPEG -quality 100 -sampling-factor 1x1 -enhance a.jpg b.jpg "); echo "<img src='b.jpg'>"; Hi guys I am trying to use image magick with php to draw an image but when i run the script it doens't show anything. All I get is an a blank page. Does anyone know if I am doing this right. Here is my code. Code: [Select] <?php echo "<pre>"; system("type convert"); echo "</pre>"; ?> <br /> <br /> <br /> <br /> <br /> <?php exec("/usr/bin/convert -size 200x200 xc:black -stroke black -strokewidth 1 \\ -fill white -draw \"circle 100,100 100,10 \" \\ -fill black -draw \"circle 100,100 100,30 \" \\ -fill blue -draw \"circle 100,100 100,50 \" \\ -fill red -draw \"circle 100,100 100,70 \" \\ -fill yellow -draw \"circle 100,100 100,90 \" \\ -fill none -draw \"circle 100,100 100,20 \" \\ -fill none -draw \"circle 100,100 100,60 \" \\ -fill none -draw \"circle 100,100 100,80 \" \\ -fill none -draw \"circle 100,100 100,95 \" \\ -stroke white -fill none \\ -draw \"circle 100,100 100,40 \" circle.png"); ?> My results are these: convert is /usr/bin/convert I really need some help with this. I haven't been able to find anything online. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=309442.0 |