-1

I currently have a section of my site where the user uploads a picture and provide their first and last name...

Is there a way that there name can be embedded into there picture and then saved?

2 Answers2

0

A Watermark will fill your needs :)

   <?php
    function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) { 
       list($width, $height) = getimagesize($SourceFile);
       $image_p = imagecreatetruecolor($width, $height);
       $image = imagecreatefromjpeg($SourceFile);
       imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); 
       $black = imagecolorallocate($image_p, 0, 0, 0);
       $font = 'arial.ttf';
       $font_size = 10; 
       imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText);
       if ($DestinationFile<>'') {
          imagejpeg ($image_p, $DestinationFile, 100); 
       } else {
          header('Content-Type: image/jpeg');
          imagejpeg($image_p, null, 100);
       };
       imagedestroy($image); 
       imagedestroy($image_p); 
    };
    ?>

Source: http://www.phpjabbers.com/put-watermark-on-images-using-php-php20.html

ffmpe
  • 55
  • 5
-1

You have a lot of possibilities to do that. It depends on the infrastructure, the servers and the languages/technologies you are using or want to use...

1) You can store the meta-data in a database and add the link to the picture to it. (a often very used way)

2) you can store the meta-data in the database and the picture file as well

3) you can try to handle with exif data (How do I add exif data to an image?) (I've never done that)

4) another way would be to store the meta-data in a xml file wich is stored at the same place than the picture...

Community
  • 1
  • 1
ffmpe
  • 55
  • 5
  • How would I do option 4? The user is supplying their name and their picture – stackoverflow Jul 23 '13 at 20:08
  • When the upload is done, you just have to write in a XML file (created by yourself just before).. Ithink you're working in PHP right? – ffmpe Jul 23 '13 at 20:10
  • yes... i want to implement it with http://tutorialzine.com/2011/04/jquery-webcam-photobooth/ – stackoverflow Jul 23 '13 at 20:11
  • I think in this case, one XML file in the folder is enough. So you'll have a list like : Name... foo.jpg (for each file...) – ffmpe Jul 23 '13 at 20:14
  • Ah.. and the only info you want to store is the name and the name of the person? If it's that, be simple, just rename the photo like "name_photo.jpg" – ffmpe Jul 23 '13 at 20:17
  • Okay... But then I also want to embed the person's name into there photo.. like another layer – stackoverflow Jul 23 '13 at 20:21
  • "another layer"?... I'm not sure to understand.. – ffmpe Jul 23 '13 at 20:25
  • like let's say my name is bob and i upload a picture of me.. Before the image is saved into the website file, I want it to say bob on the left hand corner of the picture – stackoverflow Jul 23 '13 at 20:26
  • okay so like a copyright like a watermark? ---> http://php.net/manual/en/image.examples.merged-watermark.php – ffmpe Jul 23 '13 at 20:27
  • yes that something similiar.. how would i do that with a user inputted name? – stackoverflow Jul 23 '13 at 20:35
  • simply with PHP: http://www.phpjabbers.com/put-watermark-on-images-using-php-php20.html – ffmpe Jul 23 '13 at 20:38