Is there any way to add Copyright info to the image file created by PHP
?
To be clearer, you can add copyright
info to a file with photoshop, so when you get its properties
, you see something similar to:
I want to Add/Edit Details info of a file in php. Is is possible?
EDIT:
I get an image from user input, then resize it with this function:
function image_resize($src, $w, $h, $dst, $width, $height, $extension )
{
switch($extension){
case 'bmp': $img = imagecreatefromwbmp($src); break;
case 'gif': $img = imagecreatefromgif($src); break;
case 'jpg': $img = imagecreatefromjpeg($src); break;
case 'png': $img = imagecreatefrompng($src); break;
default : return "Unsupported picture type!";
}
$new = imagecreatetruecolor($width, $height);
// preserve transparency
if($extension == "gif" or $extension == "png"){
imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
imagealphablending($new, true);
imagesavealpha($new, false);
}
imagecopyresampled($new, $img, 0, 0, 0, 0, $width, $height, $w, $h);
imageinterlace($new,1);//for progressive jpeg image
switch($extension){
case 'bmp': imagewbmp($new, $dst); break;
case 'gif': imagegif($new, $dst); break;
case 'jpg': imagejpeg($new, $dst); break;
case 'png': imagepng($new, $dst); break;
}
return true;
}
I don't believe that PHP natively contains a function to edit the EXIF data in a JPEG file, however there is a PEAR extension that can read and write EXIF data.
Website for the module is at http://lsolesen.github.io/pel/ and an example for setting the description is at https://github.com/lsolesen/pel/blob/master/examples/edit-description.php
UPDATE:
It seems the pearhub.org site is down / gone forever, but you can download the files from GitHub (no installation / setup required, just include the
autoload.php
file).Below is an example to set the copyright field in a JPEG file. Files downloaded from GitHub are placed in a subdirectory called
pel
though you can place them where-ever you like (just update therequire_once
line).