Jump to content

Recommended Posts

ok, without writing the code completely:

1, create an image large enough for both images (imagecreate)

2, open picture your first picture (imagecreatefromjpeg/gif, etc)

3, place picture on canvass created in step 1 (imagecopy/imagecopyresized, etc)

4, repeat steps 2 and 3 for second picture, or however many pictures you want

5, send the headers: header("Content-type: image/jpeg");

6, out the image created in step 1 (imagejpeg)


ok sod it, here's an example:

[code]
$canvass = imagecreate(800, 600);

$im1 = imagecreatefromjpeg('mypic_one.jpg');
imagecopy($canvass, $im1, 20,30,0,0,100,100);

$im2 = imagecreatefromjpeg('mypic_two.jpg');
imagecopy($canvass, $im2, 200,300,0,0,120,70);

imagedestroy($im1);
imagedestroy($im2);

header("Content-type: image/jpeg");
imagejpeg($canvass);
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-21866
Share on other sites

thanks for the help. it has gotten me started some, but I'm having a little trouble. Here is my current code:
[code]
<?php

$size1 = getimagesize('wolverine.jpg');
$canvas = imagecreate(($size1[0] + 20), ($size1[1]+20));

$im1 = imagecreatefromjpeg('wolverine.jpg');
imagecopy( $canvas, $im1, 0, 0, 0, 0, $size1[0], $size1[1] );

$size2 = getimagesize('box.jpg');
$im2 = imagecreatefromjpeg('box.jpg');
imagecopy($canvas, $im2, 200, 300, 0, 0, $size2[0], $size2[1] );

header("Content-type: image/gif");
imagegif($canvas);

imagedestroy($im1);
imagedestroy($im2);

?>[/code]
And here is the output: gone
and here is the source image: gone

My questions are: [ol type=\'1\'][*]Why is the canvas showing up gray when I didn't allocate any color vaules to it? [*]Why is the image of wolverine appear to have an alpha set of around 60-70? He looks grey-ed out.[*]How do I control the "Z" or depth index? It is simply a matter of the order of calling imagecopy()?[/ol]Thanks for your time and help thus far!

Cheers!
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-22070
Share on other sites

1, because something is wrong with box.jpg (either its format/loading, etc), or box.jpg is a grey box. try loading it seperately just with:

[code]
$im = imagecreatefromjpeg('/full/path/to/box.jpg');

header("Content-type: image/jpeg");
imagejpeg($im);
[/code]

2, no idea. possibly you may consider using imagecreatetruecolor instead of imagecreate, as they look like quite hi-res pictures.
3, everything done overwrites a previous action, just like a painters canvass. so yep - whatever you want on top should be the last thing you actually copy/write.
4, even tho you didn't have a 4th question - nice pictures.

hope that helps
Cheers
Mark
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-22114
Share on other sites

You seem to have a surplus image. Try without the canvas and output as jpg

<?php
$im1 = imagecreatefromjpeg('wolverine.jpg');

$size2 = getimagesize('box.jpg');
$im2 = imagecreatefromjpeg('box.jpg');
imagecopy($im1, $im2, 200, 300, 0, 0, $size2[0], $size2[1] );

header("Content-type: image/jpg");
imagejpeg($im1);

imagedestroy($im1);
imagedestroy($im2);

?>
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-22122
Share on other sites

[!--quoteo(post=359839:date=Mar 29 2006, 05:48 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 29 2006, 05:48 PM) [snapback]359839[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You seem to have a surplus image. Try without the canvas and output as jpg
[/quote]
Yes! That looks much better. However, do you have a link or can describe by what you mean of: [b]"You seem to have a surplus image"[/b]?

Also, before I read you post I made this little application: [a href=\"http://www.modernmusicians.com/help/test.swf\" target=\"_blank\"]HERE[/a]. Whenver you click on "generate image" the image qualitly isn't very good. Do you (anyone) have any idea why that is? The code I am using for that is as follows:

[code]
<?php

$canvas = imagecreatetruecolor( 300, 350 );

$size1 = getimagesize('red.jpg');
$im1 = imagecreatefromjpeg('red.jpg');
imagecopy( $canvas, $im1, $_POST['rX'], $_POST['rY'], 0, 0, $size1[0], $size1[1] );

$size2 = getimagesize('blue.jpg');
$im2 = imagecreatefromjpeg('blue.jpg');
imagecopy($canvas, $im2, $_POST['bX'], $_POST['bY'], 0, 0, $size2[0], $size2[1] );

header("Content-type: image/jpeg");
imagejpeg($canvas);

imagedestroy($im1);
imagedestroy($im2);
imagedestroy($canvas);

?>[/code]

Thanks for all the help guys!
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-22200
Share on other sites

[!--quoteo(post=360985:date=Apr 2 2006, 10:47 PM:name=flash gordon)--][div class=\'quotetop\']QUOTE(flash gordon @ Apr 2 2006, 10:47 PM) [snapback]360985[/snapback][/div][div class=\'quotemain\'][!--quotec--]
last bump.
[/quote]

i think the quality output from 'imagejpeg' defaults to 75, although it shouldn't really mess things up that much.

try

[code]
imagejpeg($canvas, "", 100);
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-23252
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value [b](about 75)[/b].
[/quote]

thanks bully!
Link to comment
https://forums.phpfreaks.com/topic/6073-gd-library-help/#findComment-23337
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.