?
Solved

Php graphics library

Posted on 2011-10-02
9
Medium Priority
?
254 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:jazzIIIlove
  • 5
  • 4
9 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36899631
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 36899671
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36899862
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Author Comment

by:jazzIIIlove
ID: 36900088
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36900582
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 36900701
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 36900702
left bottom.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 36900917
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
 
LVL 12

Author Closing Comment

by:jazzIIIlove
ID: 36901787
Classic Ray!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question