Php graphics library

Hi there;

I need a library for a PHP project of mine, which I intend to make a badge for an avatar of a user. Could you provide a library for this?

Kind regards.
LVL 12
jazzIIIloveAsked:
Who is Participating?
 
Ray PaseurCommented:
http://www.laprbass.com/RAY_temp_jazzIIIlove.php
<?php // RAY_temp_jazzIIIlove.php
error_reporting(E_ALL);

// LOCATION OF THE IMAGES (COULD COME IN FROM $_GET URL STRING)
$original = 'http://www.LAPRBass.com/RAY_junk/anime.png';
$overlay  = 'http://www.LAPRBass.com/RAY_junk/girls_minarets.png';

// READ THE IMAGE AND THE OVERLAY FILE
// MAN PAGE http://php.net/manual/en/function.imagecreatefrompng.php
$im = ImageCreateFromPNG($original);
$wm = ImageCreateFromPNG($overlay);

// ADD OVERLAY USING LOCAL FUNCTION
imagelogo($im, $wm, imagesx($im), imagesy($im), imagesx($wm), imagesy($wm));

// SHOW THE IMAGE
header('Content-type: image/png');
ImagePNG($im);

// A FUNCTION TO ADD THE OVERLAY
// SEE http://php.net/manual/en/function.imagealphablending.php#77085
function imagelogo (&$dst_image, $src_image, $dst_w, $dst_h, $src_w, $src_h)
{
    ImageAlphaBlending($dst_image,TRUE);
    ImageAlphaBlending($src_image,TRUE);
    ImageCopy
    ( $dst_image
    , $src_image
    , 0
    , ($dst_h-$src_h)
    , 0
    , 0
    , $src_w
    , $src_h
    )
    ;
}

Open in new window

0
 
Ray PaseurCommented:
Uhh, not sure I understand the question.  Do you have the PHP GD library installed?  You can use this script to see what is included in your PHP installation.

<?php phpinfo();
0
 
jazzIIIloveAuthor Commented:
What I want to do is that suppose that I have an avatar/pic that I want to put a small pic in the very corner of it, that the users should be able to do it. So is it possible with GD?

Any example codes  manipulating a pic would be perfect.

Kind regards.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Ray PaseurCommented:
Sure it's entirely possible and many web sites do it all the time to watermark copyrighted images.   Please post an example of the images you want to combine and I'll show you exactly how to do it.
0
 
jazzIIIloveAuthor Commented:
Sure;

You may need to resize the photos.

But the issue is that I want the user to assign the badge to the avatar.

Looking forward to your message

Kind regards
untitled2.bmp
wallpaper-113696.jpg
0
 
Ray PaseurCommented:
OK, I have the two photos.  One is girls-and-minarets (604x256).  One is anime-paper (1600x1200).  What do you want to do with these images?  Which goes where and how large?  It's easy to do but we need to have some fairly clear instructions about how to handle these.  An example might be, "Take the anime-paper, make it 160x120 pixels and put it over the upper-left corner of girls-and-minarets."

Also, I do not know if this matters to you, but PHP GD library is very competent with JPG and PNG images, but does not work well with BMP images.  I have come to prefer PNG images for everything I do because they do not suffer from "lossy" compression like JPG images.  PNG images have some compression, though not as much as JPG images.  But the fact that they can be stored and transmitted without losing image quality trumps the compression, in my opinion.
0
 
jazzIIIloveAuthor Commented:
The girls will be going to the left hand side of the anime. Any size.

Ah, you can convert the image type to whatever you want

I am flexible by all means.

How can we do this in php?

Regards.
0
 
jazzIIIloveAuthor Commented:
left bottom.
0
 
jazzIIIloveAuthor Commented:
Classic Ray!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.