Last active
August 29, 2015 14:01
-
-
Save kaitwalla/c2e2e4ad898c8fc27156 to your computer and use it in GitHub Desktop.
Change EXIF data in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once('/../pel/PelDataWindow.php'); | |
require_once('/../pel/PelJpeg.php'); | |
$filename = $_GET['file']; | |
// If your files are stored in a different directory, you'll want to add the directory structure here, before $filename | |
$file = $filename; | |
// This assumes you're using a form. Change the $caption as you'll need (if loop, etc.) | |
$caption = $_GET['caption']; | |
$pic = new PelJpeg($file); | |
/* Create and add empty Exif data to the image (this throws away any | |
* old Exif data in the image). */ | |
$exif = new PelExif(); | |
$pic->setExif($exif); | |
/* Create and add TIFF data to the Exif data (Exif data is actually | |
* stored in a TIFF format). */ | |
$tiff = new PelTiff(); | |
$exif->setTiff($tiff); | |
$ifd0 = new PelIfd(PelIfd::IFD0); | |
$tiff->setIfd($ifd0); | |
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $caption); | |
/* This will insert the newly created entry with the description | |
* into the IFD. */ | |
$ifd0->addEntry($desc); | |
//This overwrites the existing file. Change the location if you want to save a copy | |
$pic->saveFile($file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment