Jump to content

Exif to a new created image


Mitza

Recommended Posts

Hey.

 

I made a script to add a border and my name to a image. It looks like this (part of it, excuse me if you find some errors, but it's not the whole script):

 

    header ("Content-type: image/jpeg");
    $add="/.../".$_REQUEST["img"];
    $im=ImageCreateFromJpeg($add);
    $width=ImageSx($im);
    $height=ImageSy($im);

    $border=12; 
    $font_nume = "/.../fonts/2.ttf";
    $text_nume = "Mihai Mustea";
    $font_site = "/.../fonts/4.ttf";
    $text_site = "blog.mitza.org";
    $font_cr = "/.../fonts/3.ttf";
    $text_cr = "©";
    $font_ni = "/.../fonts/3.ttf";
    $img_adj_width=$width+(2*$border);
    $img_adj_height=$height+(2*$border) + 50;
    $newimage=imagecreatetruecolor($img_adj_width,$img_adj_height);

    $border_color = imagecolorallocate($newimage, 0, 0, 0);
    $text_color_cr = imagecolorallocate($newimage, 0, 0, 0);
    $text_color_nume_alb = imagecolorallocate($newimage, 255, 255, 255);
    $text_color_nume_port = imagecolorallocate($newimage, 255, 69, 0);
    $text_color_site_gri = imagecolorallocate($newimage, 90, 90, 90);
    $text_color_linie_1 = imagecolorallocate($newimage, 33, 33, 33);
    $text_color_linie_2 = imagecolorallocate($newimage, 66, 66, 66);
    imagefilledrectangle($newimage,0,0,$img_adj_width,$img_adj_height,$border_color);
    $wn = $img_adj_width / 2 - 65;
    $hn = $img_adj_height - 31;
    $ws = $img_adj_width / 2 - 40;
    $hs = $img_adj_height - 11;
    $wc = $width - 30;
    $hc = 25;
    $image = explode(".", $_REQUEST["img"]);
    $image = str_replace("-", " ", $image[0]);
    $image = strtoupper($image);
    
    $string1 = imagettftext($newimage, "20", "0", $wn+22, $hn, $text_color_nume_alb, $font_nume, "Mihai M.");
    $string3 = imagettftext($newimage, "14", "0", $ws, $hs, $text_color_site_gri, $font_site, "blog.");
    $string4 = imagettftext($newimage, "14", "0", $ws+33, $hs, $text_color_nume_port, $font_site, "mitza");
    $string5 = imagettftext($newimage, "14", "0", $ws+75, $hs, $text_color_site_gri, $font_site, ".org");
    $string5 = imagettftext($newimage, "8", "0", 20, $hs, $text_color_site_gri, $font_ni, $image);

    
    imageCopyResized($newimage,$im,$border,$border,0,0,$width,$height,$width,$height);
    ImageJpeg($newimage, NULL, "100");

 

Basicaly, the script creates a new black background image, adds the text from the footer and after that it adds the original resized image to the black one (eg: http://blog.mitza.org/foto/i/hell-dawn-1.jpg). The "..." is actualy a valid path in the script, I just modified it for this post. As you may already know, PHP-GD (and PHP-EXIF can only read the headers from the image) has no function to write EXIF data to the image. How can I add some EXIF information in the image, without having to create it on the hard disk (save it and than use some classes). Is there any way?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/112782-exif-to-a-new-created-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.