[PHP] imagecopy() no errors, but does nothing :-(
What I'm planning to do is to add the logo of the site over every image uploaded. Here is the code after upload: $dst_im = @ImageCreateFromJPEG ("../".$pathImg.$NomeFile); $src_im = @ImageCreateFromJPEG ("../imgsite/logo.jpg"); $dst_size = GetImageSize("../".$pathImg.$NomeFile);//800x600 $src_size = GetImageSize("../imgsite/logo.jpg");//50x50 ImageCopy( $dst_im, $src_im, 150, 150, 0, 0, 50, 50); I don't get errors but it happens nothing to the original img ($dst_im). The image logo.jpg is 50x50 and the $dst_img is 800x600. Thanks for your help, Evan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] imagecopy or why men don't use maps.
Help! I have an image file which is a map of the local area. I want to put symbols on the map at various points, but I first need to get the php image function to work. My site has imaging enabled and I can create graphs from scratch, but this has stumped me so far. Any help will be greatly appreciated. Hugh code? below: $image=imagecreate(400,400); // created image // source image info $source="map1.jpg"; $imageinfo = getimagesize($source); $source_00=0; // origin (0,0) $source_width=$imageinfo[0]; $source_height-$imageinfo[1]; $image_00=0; // origin (0,0) imagecopy($image,$source, $image_00, $image_00, $source_00, $source_00, $source_width, $source_height); / / this is line 36. Warning: Supplied argument is not a valid Image resource in /www/site.com/somepage.php on line 36
[PHP] ImageCopy() not working
I created a function (appears below) that crops a JPG and outputs it on the fly. However Apache crashes when I use the function. Unfortunately, Apache does not put an error message in the logs. I'm running it on a Windows2000 machine with Apache 1.3.20 and PHP 4.0.6 (installed via EasyPHP 1.5.0.0). I've isolated the problem to be the ImageCopy() function, I'm sure of this. If I use ImageCopyMerge() instead (with pct = 100), it works albeit with varying results. Has anyone else encountered this? Does anyone know how to fix it? ---snip--- function ImageCropJPEG( $src_file, $dst_file, $dst_width, $dst_height, $quality = '100', $crop_type = 'r' ) { // Must be a valid file if ( is_file( $src_file ) ) { // Get image dimensions list( $src_width, $src_height, $src_type ) = @GetImageSize( $src_file ); // Must be a valid JPEG if ( is_set( $src_width ) && is_set( $src_height ) && $src_type == 2 ) { // Generate crop coords switch ( $crop_type ) { // Centered crop coords case 'c': $src_x = max( 1, floor( ( $src_width - $dst_width ) / 2 ) ); $src_y = max( 1, floor( ( $src_height - $dst_height ) / 2 ) ); break; // Random crop coords case 'r': default: $src_x = mt_rand( 0, max( 1, $src_width - $dst_width - 1 ) ); $src_y = mt_rand( 0, max( 1, $src_height - $dst_height - 1 ) ); break; } // Create resources pointers for source and destination images $src_image = ImageCreateFromJPEG( $src_file ); $dst_image = ImageCreate( $dst_width, $dst_height ); // Copy cropped portion of source image to destination image ImageCopy( $dst_image, $src_image, 0, 0, $src_x, $src_y, $dst_width, $dst_height ); #ImageCopyMerge( $dst_image, $src_image, 0, 0, $src_x, $src_y, $dst_width, $dst_height, 100 ); // testing... // Output to STDOUT if ( empty( $dst_file ) ) { header( 'Content-type: image/jpeg' ); } // Output image ImageJPEG( $dst_image, $dst_file, $quality ); // Free any memory associated the source and destination images ImageDestroy( $src_image ); ImageDestroy( $dst_image ); } } return( TRUE ); } ---snip--- Forgive me if this has been asked before. I searched the archives but couldn't find the answer. TIA! geoff.catlin programmer#Q15439 --- http://www.3rdkynd.com http://www.urthling.com 3rdkynd :: From the electricity of the edge to the subtlety of the sublime, we've got what you've been looking for. e :: [EMAIL PROTECTED] p :: 315.685.3415 f :: 315.685.5159
RE: [PHP] imageCopy :-(
Hello! You should open "test.bmp" first. Best regards, Andrew Kirilenko. > -Original Message- > From: jtjohnston [mailto:[EMAIL PROTECTED]] > Sent: Saturday, November 10, 2001 1:15 PM > To: [EMAIL PROTECTED] > Subject: [PHP] imageCopy :-( > > > Not that I'm sleep deprived ... :o) > > Simple, I create an image, add a bunch of text and what not. > Now I want to add a graphic. (Probably a couple, who knows?) > > imageCopy("test.bmp",$image,10,10,10,10,350,500,50); <== doesn't > work. > > Is this even the right function?? > > Description: > int ImageCopyMerge (resource dst_im, resource, src_im, > int dst_x, = 10 > int dst_y, = 10 > int src_x, = 10 > int src_y, = 10 > int src_w, = 350 > int src_h, = 500 > int pct = 50 > ) > > So what am I doing wrong? > > snip--- > header("Content-type: image/png"); > > $height = 350; > $width = 500; > $image = imagecreate($width, $height+350); > > $white = imagecolorallocate($image, 255, 255, 255); > $red = imagecolorallocate($image, 255, 0, 0); > $green = ImageColorAllocate($image, 0, 255, 0); > $blue = ImageColorAllocate($image, 0, 0, 255); > $black = imagecolorallocate($image, 0, 0, 0); > > ImageString($image,5,30, 30 +350, "hello",$blue); > > imageCopy("test.bmp",$image,10,10,10,10,350,500,50); > > imagepng($image); > imagedestroy($image); > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] imageCopy :-(
Not that I'm sleep deprived ... :o) Simple, I create an image, add a bunch of text and what not. Now I want to add a graphic. (Probably a couple, who knows?) imageCopy("test.bmp",$image,10,10,10,10,350,500,50); <== doesn't work. Is this even the right function?? Description: int ImageCopyMerge (resource dst_im, resource, src_im, int dst_x, = 10 int dst_y, = 10 int src_x, = 10 int src_y, = 10 int src_w, = 350 int src_h, = 500 int pct = 50 ) So what am I doing wrong? snip--- header("Content-type: image/png"); $height = 350; $width = 500; $image = imagecreate($width, $height+350); $white = imagecolorallocate($image, 255, 255, 255); $red = imagecolorallocate($image, 255, 0, 0); $green = ImageColorAllocate($image, 0, 255, 0); $blue = ImageColorAllocate($image, 0, 0, 255); $black = imagecolorallocate($image, 0, 0, 0); ImageString($image,5,30, 30 +350, "hello",$blue); imageCopy("test.bmp",$image,10,10,10,10,350,500,50); imagepng($image); imagedestroy($image); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] ImageCopy
I am creating an image on the fly based on newest entries in one my mySQL tables. In this created image I am trying to add a small one to it. Now I am TRYING to use the below code: $image = ImageCreate(500, 70); $bg = ImageColorAllocate($image, 255, 255, 255); $blue = ImageColorAllocate($image, 0, 0, 255); $black = ImageColorAllocate($image, 0, 0, 0); $himage= "usr/hyrum/public_html/images/topics/hyrum.gif"; ImageRectangle($image, 0, 0, 500, 70, $white); ImageString($image, 4, 0, 0, $text, $blue); ImageString($image, 3, 0, 20, $title1, $black); ImageString($image, 3, 0, 35, $title2, $black); ImageString($image, 3, 0, 50, $title3, $black); //ImageCopy($image, $himage, 400, 20, 1, 1, 60, 60) Imagepng($image, "signature.png"); ImageDestroy($image); Am I using ImageCopy incorrectly? It doesn't put anything in the new image. Jeff