本文整理汇总了PHP中PelJpeg类的典型用法代码示例。如果您正苦于以下问题:PHP PelJpeg类的具体用法?PHP PelJpeg怎么用?PHP PelJpeg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PelJpeg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testThisDoesNotWorkAsExpected
function testThisDoesNotWorkAsExpected()
{
$subject = "Превед, медвед!";
$data = new PelDataWindow(file_get_contents($this->file));
if (PelJpeg::isValid($data)) {
$jpeg = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if (null == $exif) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
if (null == $ifd0) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
}
$ifd0->addEntry(new PelEntryWindowsString(PelTag::XP_SUBJECT, $subject));
file_put_contents($this->file, $jpeg->getBytes());
$jpeg = new PelJpeg($this->file);
$exif = $jpeg->getExif();
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
$written_subject = $ifd0->getEntry(PelTag::XP_SUBJECT);
$this->assertEqual($subject, $written_subject->getValue());
}
示例2: testRead
function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/no-exif.jpg');
$exif = $jpeg->getExif();
$this->assertNull($exif);
$this->assertTrue(count(Pel::getExceptions()) == 0);
}
示例3: rotate_item
static function rotate_item($item)
{
require_once MODPATH . 'autorotate/lib/pel/PelDataWindow.php';
require_once MODPATH . 'autorotate/lib/pel/PelJpeg.php';
require_once MODPATH . 'autorotate/lib/pel/PelTiff.php';
// Only try to rotate photos based on EXIF
if ($item->is_photo() && $item->mime_type == "image/jpeg") {
require_once MODPATH . "exif/lib/exif.php";
$exif_raw = read_exif_data_raw($item->file_path(), false);
if (isset($exif_raw['ValidEXIFData'])) {
$orientation = $exif_raw["IFD0"]["Orientation"];
$degrees = 0;
if ($orientation == '3: Upside-down') {
$degrees = 180;
} else {
if ($orientation == '8: 90 deg CW') {
$degrees = -90;
} else {
if ($orientation == '6: 90 deg CCW') {
$degrees = 90;
}
}
}
if ($degrees) {
$tmpfile = tempnam(TMPPATH, "rotate");
gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees));
// Update EXIF info
$data = new PelDataWindow(file_get_contents($tmpfile));
if (PelJpeg::isValid($data)) {
$jpeg = $file = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if ($exif !== null) {
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
$orientation = $ifd0->getEntry(PelTag::ORIENTATION);
$orientation->setValue(1);
file_put_contents($tmpfile, $file->getBytes());
}
}
$item->set_data_file($tmpfile);
$item->save();
unlink($tmpfile);
}
}
}
return;
}
示例4: testThisDoesNotWorkAsExpected
function testThisDoesNotWorkAsExpected()
{
$tmpfile = dirname(__FILE__) . '/images/bug1730993_tmp.jpg';
$bigfile = dirname(__FILE__) . '/images/bug1730993_large.jpg';
try {
$jpeg = new PelJpeg($tmpfile);
// the error occurs here
$exif = $jpeg->getExif();
if ($exif != null) {
$jpeg1 = new PelJpeg($bigfile);
$jpeg1->setExif($exif);
file_put_contents($bigfile, $jpeg1->getBytes());
}
} catch (Exception $e) {
$this->fail('Test should not throw an exception');
}
}
示例5: testThisDoesNotWorkAsExpected
function testThisDoesNotWorkAsExpected()
{
$filename = dirname(__FILE__) . '/images/bug3017880.jpg';
try {
$exif = null;
$success = 1;
// return true by default, as this function may not resave the file, but it's still success
$resave_file = 0;
$jpeg = new PelJpeg($filename);
// should all exif data on photo be cleared (gd and iu will always strip it anyway, so only
// force strip if you know the image you're branding is an original)
//$jpeg->clearExif();
if ($exif === null) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
if ($ifd0 == null) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
$software_name = 'Example V2';
$software = $ifd0->getEntry(PelTag::SOFTWARE);
if ($software == null) {
$software = new PelEntryAscii(PelTag::SOFTWARE, $software_name);
$ifd0->addEntry($software);
$resave_file = 1;
echo 'null';
} else {
$software->setValue($software_name);
$resave_file = 1;
echo 'update';
}
if ($resave_file == 1 && !file_put_contents($filename, $jpeg->getBytes())) {
// if it was okay to resave the file, but it did not save correctly
$success = 0;
}
} catch (Exception $e) {
$this->fail('Test should not throw an exception');
}
}
示例6: testThisDoesNotWorkAsExpected
function testThisDoesNotWorkAsExpected()
{
$scale = 0.75;
$input_jpeg = new PelJpeg($this->file);
$original = ImageCreateFromString($input_jpeg->getBytes());
$original_w = ImagesX($original);
$original_h = ImagesY($original);
$scaled_w = $original_w * $scale;
$scaled_h = $original_h * $scale;
$scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
$output_jpeg = new PelJpeg($scaled);
$exif = $input_jpeg->getExif();
if ($exif != null) {
$output_jpeg->setExif($exif);
}
file_put_contents($this->file, $output_jpeg->getBytes());
$jpeg = new PelJpeg($this->file);
$exifin = $jpeg->getExif();
$this->assertEqual($exif, $exifin);
}
示例7: testWriteRead
function testWriteRead()
{
Pel::setStrictParsing(true);
$ifd = new PelIfd(PelIfd::IFD0);
$this->assertTrue($ifd->isLastIfd());
foreach ($this->entries as $entry) {
$ifd->addEntry($entry);
}
$tiff = new PelTiff();
$this->assertNull($tiff->getIfd());
$tiff->setIfd($ifd);
$this->assertNotNull($tiff->getIfd());
$exif = new PelExif();
$this->assertNull($exif->getTiff());
$exif->setTiff($tiff);
$this->assertNotNull($exif->getTiff());
$jpeg = new PelJpeg(dirname(__FILE__) . '/no-exif.jpg');
$this->assertNull($jpeg->getExif());
$jpeg->setExif($exif);
$this->assertNotNull($jpeg->getExif());
$jpeg->saveFile('test-output.jpg');
$this->assertTrue(file_exists('test-output.jpg'));
$this->assertTrue(filesize('test-output.jpg') > 0);
/* Now read the file and see if the entries are still there. */
$jpeg = new PelJpeg('test-output.jpg');
$exif = $jpeg->getExif();
$this->assertIsA($exif, 'PelExif');
$tiff = $exif->getTiff();
$this->assertIsA($tiff, 'PelTiff');
$ifd = $tiff->getIfd();
$this->assertIsA($ifd, 'PelIfd');
$this->assertEqual($ifd->getType(), PelIfd::IFD0);
$this->assertTrue($ifd->isLastIfd());
foreach ($this->entries as $entry) {
$this->assertEqual($ifd->getEntry($entry->getTag())->getValue(), $entry->getValue());
}
unlink('test-output.jpg');
}
示例8: addGPSdata
function addGPSdata($infile, $outfile, $GPS_lat, $GPS_lon, $GPS_alt)
{
try {
$image = new PelJpeg($infile);
} catch (Exception $exc) {
return -1;
}
if ($image instanceof PelJpeg) {
if ($image->isValid(new PelDataWindow($image->getBytes()))) {
$exif = $image->getExif();
if ($exif == null) {
$exif = new PelExif();
$image->setExif($exif);
$exif->setTiff(new PelTiff());
}
$tiff = $exif->getTiff();
$ifd0 = $tiff->getIfd();
if ($ifd0 == null) {
$ifd0 = new PelIFD(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
/* Tags erzeugen */
$subifd = new PelIfd(PelIfd::GPS);
$GPS_latref = $GPS_lat < 0 ? "S" : "N";
$GPS_lonref = $GPS_lon < 0 ? "W" : "E";
$GPS_altref = $GPS_alt < 0 ? 1 : 0;
list($degrees, $minutes, $milliseconds) = dec2dms(abs($GPS_lat));
$gpslat = new PelEntryRational(PelTag::GPS_LATITUDE, array($degrees, 1), array($minutes, 1), array($milliseconds, 1000));
list($degrees, $minutes, $milliseconds) = dec2dms(abs($GPS_lon));
$gpslon = new PelEntryRational(PelTag::GPS_LONGITUDE, array($degrees, 1), array($minutes, 1), array($milliseconds, 1000));
echo $GPS_alt * 1000;
$gpsalt = new PelEntryRational(PelTag::GPS_ALTITUDE, array(abs($GPS_alt * 1000), 1000));
$gpslatref = new PelEntryAscii(PelTag::GPS_LATITUDE_REF, $GPS_latref);
$gpslonref = new PelEntryAscii(PelTag::GPS_LONGITUDE_REF, $GPS_lonref);
$gpsaltref = new PelEntryByte(PelTag::GPS_ALTITUDE_REF, $GPS_altref);
$gpsversion = new PelEntryByte(PelTag::GPS_VERSION_ID, 2, 2, 0, 0);
/* Daten eintragen.*/
$subifd->addEntry($gpsversion);
$subifd->addEntry($gpslat);
$subifd->addEntry($gpslon);
$subifd->addEntry($gpsalt);
$subifd->addEntry($gpslatref);
$subifd->addEntry($gpslonref);
$subifd->addEntry($gpsaltref);
$ifd0->addSubIfd($subifd);
file_put_contents($outfile, $image->getBytes());
return 0;
}
}
return -1;
}
示例9: updateDescription
/**
* Updates the description of an image with the given data
*
* @param $id The internal id of the image
* @param $title The title of the image
* @param $description The description of the image
* @param $category The category of the image
* @param $tags An array of tags of the image
*/
public function updateDescription($filename, $id, $title, $description, $category, $tags)
{
$data = new PelDataWindow(file_get_contents($filename));
if (PelJpeg::isValid($data)) {
$jpeg = $file = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if ($exif == null) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
} else {
$tiff = $exif->getTiff();
}
} elseif (PelTiff::isValid($data)) {
$tiff = $file = new PelTiff();
$tiff->load($data);
} else {
return 0;
}
$ifd0 = $tiff->getIfd();
if ($ifd0 == null) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
$desc = $ifd0->getEntry(PelTag::IMAGE_DESCRIPTION);
$description = json_encode(array('id' => $id, 'Title' => $title, 'Description' => $description, 'Category' => $category, 'Tags' => implode(',', $tags)));
if ($desc == null) {
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description);
$ifd0->addEntry($desc);
} else {
$desc->setValue($description);
}
$file->saveFile($filename);
}
示例10: testRead
function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c5050z.jpg');
$exif = $jpeg->getExif();
$this->assertIsA($exif, 'PelExif');
$tiff = $exif->getTiff();
$this->assertIsA($tiff, 'PelTiff');
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertIsA($ifd0, 'PelIfd');
/* Start of IDF $ifd0. */
$this->assertEqual(count($ifd0->getEntries()), 11);
$entry = $ifd0->getEntry(270);
// ImageDescription
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'OLYMPUS DIGITAL CAMERA ');
$this->assertEqual($entry->getText(), 'OLYMPUS DIGITAL CAMERA ');
$entry = $ifd0->getEntry(271);
// Make
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'OLYMPUS OPTICAL CO.,LTD');
$this->assertEqual($entry->getText(), 'OLYMPUS OPTICAL CO.,LTD');
$entry = $ifd0->getEntry(272);
// Model
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'C5050Z');
$this->assertEqual($entry->getText(), 'C5050Z');
$entry = $ifd0->getEntry(274);
// Orientation
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 1);
$this->assertEqual($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282);
// XResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1));
$this->assertEqual($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283);
// YResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1));
$this->assertEqual($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296);
// ResolutionUnit
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305);
// Software
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'v558-83');
$this->assertEqual($entry->getText(), 'v558-83');
$entry = $ifd0->getEntry(306);
// DateTime
$this->assertIsA($entry, 'PelEntryTime');
$this->assertEqual($entry->getValue(), false);
$this->assertEqual($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0->getEntry(531);
// YCbCrPositioning
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341);
// PrintIM
$this->assertIsA($entry, 'PelEntryUndefined');
$this->assertEqual($entry->getValue(), 'PrintIM0250�
�
����������� \'\'�\'�\'\'^\'�\'�\'�\'');
$this->assertEqual($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEqual(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2);
// IFD Exif
$this->assertIsA($ifd0_0, 'PelIfd');
/* Start of IDF $ifd0_0. */
$this->assertEqual(count($ifd0_0->getEntries()), 32);
$entry = $ifd0_0->getEntry(33434);
// ExposureTime
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 10, 1 => 40));
$this->assertEqual($entry->getText(), '1/4 sec.');
$entry = $ifd0_0->getEntry(33437);
// FNumber
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 26, 1 => 10));
$this->assertEqual($entry->getText(), 'f/2.6');
$entry = $ifd0_0->getEntry(34850);
// ExposureProgram
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855);
// ISOSpeedRatings
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 64);
$this->assertEqual($entry->getText(), '64');
$entry = $ifd0_0->getEntry(36864);
// ExifVersion
//.........这里部分代码省略.........
示例11: copyEXIF
/**
* Copy the source image's EXIF information to the new file in the cache
*
* @since 2.0
* @uses PEL
* @param string $cacheFilePath
* @return mixed string contents of image on success, false on failure
*/
private function copyEXIF($cacheFilePath)
{
// Make sure to suppress strict warning thrown by PEL
require_once dirname(__FILE__) . '/../pel/src/PelJpeg.php';
$jpeg = new PelJpeg($this->getSource()->getFullPath());
$exif = $jpeg->getExif();
if ($exif !== null) {
$jpeg = new PelJpeg($cacheFilePath);
$jpeg->setExif($exif);
$imageData = $jpeg->getBytes();
if (!file_put_contents($cacheFilePath, $imageData)) {
return false;
}
return $imageData;
}
// if
return file_get_contents($cacheFilePath);
}
示例12: testRead
function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c50z.jpg');
$exif = $jpeg->getExif();
$this->assertIsA($exif, 'PelExif');
$tiff = $exif->getTiff();
$this->assertIsA($tiff, 'PelTiff');
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertIsA($ifd0, 'PelIfd');
/* Start of IDF $ifd0. */
$this->assertEqual(count($ifd0->getEntries()), 11);
$entry = $ifd0->getEntry(270);
// ImageDescription
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'OLYMPUS DIGITAL CAMERA ');
$this->assertEqual($entry->getText(), 'OLYMPUS DIGITAL CAMERA ');
$entry = $ifd0->getEntry(271);
// Make
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'OLYMPUS OPTICAL CO.,LTD');
$this->assertEqual($entry->getText(), 'OLYMPUS OPTICAL CO.,LTD');
$entry = $ifd0->getEntry(272);
// Model
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'X-2,C-50Z ');
$this->assertEqual($entry->getText(), 'X-2,C-50Z ');
$entry = $ifd0->getEntry(274);
// Orientation
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 1);
$this->assertEqual($entry->getText(), 'top - left');
$entry = $ifd0->getEntry(282);
// XResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 144, 1 => 1));
$this->assertEqual($entry->getText(), '144/1');
$entry = $ifd0->getEntry(283);
// YResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 144, 1 => 1));
$this->assertEqual($entry->getText(), '144/1');
$entry = $ifd0->getEntry(296);
// ResolutionUnit
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(305);
// Software
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), '28-1012 ');
$this->assertEqual($entry->getText(), '28-1012 ');
$entry = $ifd0->getEntry(306);
// DateTime
$this->assertIsA($entry, 'PelEntryTime');
$this->assertEqual($entry->getValue(), false);
$this->assertEqual($entry->getText(), '0000:00:00 00:00:00');
$entry = $ifd0->getEntry(531);
// YCbCrPositioning
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341);
// PrintIM
$this->assertIsA($entry, 'PelEntryUndefined');
$this->assertEqual($entry->getValue(), 'PrintIM0250ˆ
Ð
èÿ€€€€€€€€€ \'\'—\'°\'\'^\'‹\'Ë\'å\'');
$this->assertEqual($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEqual(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2);
// IFD Exif
$this->assertIsA($ifd0_0, 'PelIfd');
/* Start of IDF $ifd0_0. */
$this->assertEqual(count($ifd0_0->getEntries()), 30);
$entry = $ifd0_0->getEntry(33434);
// ExposureTime
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 1, 1 => 80));
$this->assertEqual($entry->getText(), '1/80 sec.');
$entry = $ifd0_0->getEntry(33437);
// FNumber
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 45, 1 => 10));
$this->assertEqual($entry->getText(), 'f/4.5');
$entry = $ifd0_0->getEntry(34850);
// ExposureProgram
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 5);
$this->assertEqual($entry->getText(), 'Creative program (biased toward depth of field)');
$entry = $ifd0_0->getEntry(34855);
// ISOSpeedRatings
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 80);
$this->assertEqual($entry->getText(), '80');
$entry = $ifd0_0->getEntry(36864);
// ExifVersion
//.........这里部分代码省略.........
示例13: _addExif
private function _addExif($filename)
{
//if ($_SERVER['SERVER_NAME'] == 'test.psychomorph') return true;
try {
$jpeg = new PelJpeg($filename);
if (!($exif = $jpeg->getExif())) {
// Create and add empty Exif data to the image (this throws away any old Exif data in the image).
$exif = new PelExif();
$jpeg->setExif($exif);
}
if (!($tiff = $exif->getTiff())) {
// Create and add TIFF data to the Exif data (Exif data is actually stored in a TIFF format).
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
if (!($ifd0 = $tiff->getIfd())) {
// Create first Image File Directory and associate it with the TIFF data.
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
if (!($exif_ifd = $ifd0->getSubIfd(PelIfd::EXIF))) {
// Create exif Image File Directory and associate it with the TIFF data.
$exif_ifd = new PelIfd(PelIfd::EXIF);
$ifd0->addSubIfd($exif_ifd);
}
if (!($ifd1 = $ifd0->getNextIfd())) {
// thumbnail does not exist
$ifd1 = new PelIfd(1);
$ifd0->setNextIfd($ifd1);
//$original = ImageCreateFromString($jpeg->getBytes()); # create image resource of original
//$thumb = makeThumb($original);
$thumb = $this->_makeThumb($this->getImage());
// start writing output to buffer
ob_start();
// outputs thumb resource contents to buffer
ImageJpeg($thumb);
// create PelDataWindow from buffer thumb contents (and end output to buffer)
$window = new PelDataWindow(ob_get_clean());
if ($window) {
$ifd1->setThumbnail($window);
# set window data as thumbnail in ifd1
}
//imagedestroy($original);
imagedestroy($thumb);
}
$exifdata = array(PelTag::IMAGE_DESCRIPTION => $this->getDescription(), PelTag::COPYRIGHT => "webmorph.org: " . $_SESSION['user_id'] . ': IMG_ID: ', PelTag::USER_COMMENT => $this->_embeddedTem);
foreach ($exifdata as $PelTag => $val) {
if ($PelTag == PelTag::USER_COMMENT) {
if (!($entry = $exif_ifd->getEntry($PelTag))) {
$exif_ifd->addEntry(new PelEntryUserComment($val));
} else {
$entry->setValue($val);
}
} else {
if (!($entry = $ifd0->getEntry($PelTag))) {
$ifd0->addEntry(new PelEntryAscii($PelTag, $val));
} else {
$entry->setValue($val);
}
}
}
$jpeg->saveFile($filename);
return true;
} catch (Exception $e) {
// Handle exception
echo $e;
}
}
示例14: testRead
function testRead()
{
Pel::clearExceptions();
Pel::setStrictParsing(false);
$jpeg = new PelJpeg(dirname(__FILE__) . '/sony-dsc-v1.jpg');
$exif = $jpeg->getExif();
$this->assertIsA($exif, 'PelExif');
$tiff = $exif->getTiff();
$this->assertIsA($tiff, 'PelTiff');
/* The first IFD. */
$ifd0 = $tiff->getIfd();
$this->assertIsA($ifd0, 'PelIfd');
/* Start of IDF $ifd0. */
$this->assertEqual(count($ifd0->getEntries()), 10);
$entry = $ifd0->getEntry(270);
// ImageDescription
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), ' ');
$this->assertEqual($entry->getText(), ' ');
$entry = $ifd0->getEntry(271);
// Make
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'SONY');
$this->assertEqual($entry->getText(), 'SONY');
$entry = $ifd0->getEntry(272);
// Model
$this->assertIsA($entry, 'PelEntryAscii');
$this->assertEqual($entry->getValue(), 'DSC-V1');
$this->assertEqual($entry->getText(), 'DSC-V1');
$entry = $ifd0->getEntry(274);
// Orientation
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 6);
$this->assertEqual($entry->getText(), 'right - top');
$entry = $ifd0->getEntry(282);
// XResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1));
$this->assertEqual($entry->getText(), '72/1');
$entry = $ifd0->getEntry(283);
// YResolution
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1));
$this->assertEqual($entry->getText(), '72/1');
$entry = $ifd0->getEntry(296);
// ResolutionUnit
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'Inch');
$entry = $ifd0->getEntry(306);
// DateTime
$this->assertIsA($entry, 'PelEntryTime');
$this->assertEqual($entry->getValue(), 1089482993);
$this->assertEqual($entry->getText(), '2004:07:10 18:09:53');
$entry = $ifd0->getEntry(531);
// YCbCrPositioning
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'co-sited');
$entry = $ifd0->getEntry(50341);
// PrintIM
$this->assertIsA($entry, 'PelEntryUndefined');
$this->assertEqual($entry->getValue(), 'PrintIM' . "" . '0250' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '');
$this->assertEqual($entry->getText(), '(undefined)');
/* Sub IFDs of $ifd0. */
$this->assertEqual(count($ifd0->getSubIfds()), 1);
$ifd0_0 = $ifd0->getSubIfd(2);
// IFD Exif
$this->assertIsA($ifd0_0, 'PelIfd');
/* Start of IDF $ifd0_0. */
$this->assertEqual(count($ifd0_0->getEntries()), 26);
$entry = $ifd0_0->getEntry(33434);
// ExposureTime
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 10, 1 => 600));
$this->assertEqual($entry->getText(), '1/60 sec.');
$entry = $ifd0_0->getEntry(33437);
// FNumber
$this->assertIsA($entry, 'PelEntryRational');
$this->assertEqual($entry->getValue(), array(0 => 32, 1 => 10));
$this->assertEqual($entry->getText(), 'f/3.2');
$entry = $ifd0_0->getEntry(34850);
// ExposureProgram
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 2);
$this->assertEqual($entry->getText(), 'Normal program');
$entry = $ifd0_0->getEntry(34855);
// ISOSpeedRatings
$this->assertIsA($entry, 'PelEntryShort');
$this->assertEqual($entry->getValue(), 100);
$this->assertEqual($entry->getText(), '100');
$entry = $ifd0_0->getEntry(36864);
// ExifVersion
$this->assertIsA($entry, 'PelEntryVersion');
$this->assertEqual($entry->getValue(), 2.2);
$this->assertEqual($entry->getText(), 'Exif Version 2.2');
$entry = $ifd0_0->getEntry(36867);
// DateTimeOriginal
$this->assertIsA($entry, 'PelEntryTime');
$this->assertEqual($entry->getValue(), 1089482993);
//.........这里部分代码省略.........
示例15: PelDataWindow
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program in the file COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
require_once '../share/classes/pel-0.9.1/PelDataWindow.php';
require_once '../share/classes/pel-0.9.1/PelJpeg.php';
require_once '../share/classes/pel-0.9.1/PelTiff.php';
$data = new PelDataWindow(file_get_contents($input));
if (PelJpeg::isValid($data)) {
$jpeg = $file = new PelJpeg();
$jpeg->load($data);
$exif = $jpeg->getExif();
if ($exif == null) {
$exif = new PelExif();
$jpeg->setExif($exif);
$tiff = new PelTiff();
$exif->setTiff($tiff);
} else {
$tiff = $exif->getTiff();
}
} elseif (PelTiff::isValid($data)) {
$tiff = $file = new PelTiff();
/* Now load the data. */
$tiff->load($data);