/** * Loads the EXIF data from the given file and returns it * * @param $filename Filename of the file to load the exif data from * @return The EXIF data as array */ public function load($filename) { if (!file_exists($filename)) { throw new Exception('File "' . $filename . '" not found!'); } $jpeg = new PelJpeg($filename); $exif = array(PelIfd::IFD0 => $jpeg->getExif()->getTiff()->getIfd(), PelIfd::IFD1 => $jpeg->getExif()->getTiff()->getIfd()->getNextIfd(), PelIfd::EXIF => $jpeg->getExif()->getTiff()->getIfd()->getSubIfd(PelIfd::EXIF), PelIfd::GPS => $jpeg->getExif()->getTiff()->getIfd()->getSubIfd(PelIfd::GPS)); $result = array('id' => $this->getDescriptionPart($exif, 'id'), 'Model' => str_replace('\\0', '', $this->getValue($exif[PelIfd::IFD0]->getEntry(PelTag::MODEL))), 'Flash' => $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::FLASH)), 'LensID' => $this->parseXmpData($filename, 'aux:LensID') != '' ? $this->parseXmpData($filename, 'aux:LensID') : '0', 'Lens' => $this->parseXmpData($filename, 'aux:Lens'), 'ExposureProgram' => $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::EXPOSURE_PROGRAM)), 'MeteringMode' => $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::METERING_MODE)), 'Title' => $this->getDescriptionPart($exif, 'Title'), 'Description' => $this->getDescriptionPart($exif, 'Description'), 'Category' => $this->getDescriptionPart($exif, 'Category'), 'Tags' => explode(',', $this->getDescriptionPart($exif, 'Tags')), 'DateCreated' => date('Y-m-d H:i:s', $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::DATE_TIME_ORIGINAL)) != "" ? $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::DATE_TIME_ORIGINAL)) : $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::DATE_TIME_DIGITIZED))), 'FocalLength' => $this->getFocalLength($exif), 'FNumber' => $this->getFNumber($exif), 'ExposureTime' => $this->getExposureTime($exif), 'ISO' => $this->getValue($exif[PelIfd::EXIF]->getEntry(PelTag::ISO_SPEED_RATINGS)), 'GpsLatitudeRef' => isset($exif[PelIfd::GPS]) ? $this->getValue($exif[PelIfd::GPS]->getEntry(PelTag::GPS_LATITUDE_REF)) : '', 'GpsLatitude' => isset($exif[PelIfd::GPS]) ? $this->gpsExtract($exif[PelIfd::GPS]->getEntry(PelTag::GPS_LATITUDE)->getValue()) : '', 'GpsLongitudeRef' => isset($exif[PelIfd::GPS]) ? $this->getValue($exif[PelIfd::GPS]->getEntry(PelTag::GPS_LONGITUDE_REF)) : '', 'GpsLongitude' => isset($exif[PelIfd::GPS]) ? $this->gpsExtract($exif[PelIfd::GPS]->getEntry(PelTag::GPS_LONGITUDE)->getValue()) : ''); return $result; }
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()); }
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); }
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; }
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'); } }
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); }
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'); }
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; } }
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 $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(), false); $this->assertEqual($entry->getText(), '0000:00:00 00:00:00'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), false); $this->assertEqual($entry->getText(), '0000:00:00 00:00:00'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 300, 1 => 100)); $this->assertEqual($entry->getText(), '300/100'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 25); $this->assertEqual($entry->getText(), 'Flash fired, auto mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 1883, 1 => 100)); $this->assertEqual($entry->getText(), '18.8 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'OLYMP>$8@HT Z | „ Œ ” ¤ ¸ QQ 6Hpp@&@ Üè¸ !°\'" n# $6% (&\'(d)*+T, -. /€01t3Ð 8;!¾<¾= ä> ì'); $this->assertEqual($entry->getText(), '758 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ' '); $this->assertEqual($entry->getText(), ' '); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2560); $this->assertEqual($entry->getText(), '2560'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1920); $this->assertEqual($entry->getText(), '1920'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 100, 1 => 100)); $this->assertEqual($entry->getText(), '100/100'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Portrait'); $entry = $ifd0_0->getEntry(41991); // GainControl $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41992); // Contrast $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41993); // Saturation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41994); // Sharpness $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c50z-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2); /* End of IFD $ifd1. */
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); $this->assertEqual($entry->getText(), '2004:07:10 18:09:53'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1089482993); $this->assertEqual($entry->getText(), '2004:07:10 18:09:53'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), '' . "" . ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 7, 1 => 10)); $this->assertEqual($entry->getText(), '+0.7'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 48, 1 => 16)); $this->assertEqual($entry->getText(), '48/16'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Center-Weighted Average'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 31); $this->assertEqual($entry->getText(), 'Flash fired, auto mode, return light detected.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 139, 1 => 10)); $this->assertEqual($entry->getText(), '13.9 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'SONY DSC ' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '@' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . 'd' . "" . '' . "" . '�' . "" . 'x' . "" . '' . "" . '' . "" . '~' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '������������������������������������������������' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'n~�' . "" . '�,' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�A�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . ' �' . "" . '`�^��J�' . "" . '' . "" . '' . "" . '' . "" . 'J0' . "" . '�J0J�' . "" . 'p' . "" . '' . "" . 'p' . "" . '' . "" . '�' . "" . '^' . "" . '�' . "" . '' . "" . 'V ' . "" . '' . "" . '' . "" . 'c' . "" . '' . "" . '��' . "" . '' . "" . 'Ґ��' . "" . 'p' . "" . '' . "" . '�' . "" . '�^' . "" . '�o' . "" . '' . "" . '@P' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '��' . "" . 't��' . "" . '�u=' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '�tד�g��"0c' . "" . '' . "" . '' . "" . '' . "" . 'ק�!' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '}' . "" . '(�' . "" . '^' . "" . '' . "" . '�' . "" . '����ד@' . "" . '' . "" . '' . "" . '��sF' . "" . '�' . "" . '�' . "" . '#' . "" . '#' . "" . 'G' . "" . '�' . "" . '' . "" . 'U�$1��ys�y�y��[��}����' . "" . '' . "" . 'i' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '�' . "" . '' . "" . 'G�' . "" . '' . "" . 'j' . "" . ' #' . "" . '^' . "" . '' . "" . '' . "" . 'V' . "" . '��' . "" . '' . "" . '��E�8T' . "" . 'i$�c���#(G�E�!�IX/' . "" . '�F�YZ��' . "" . '�R�nQ������������������������������������������������������� ' . "" . '�ܼ_' . "" . '' . "" . '��Q' . "" . '�' . "" . '�' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '}' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '{' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�Q' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '��' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '��' . "" . '' . "" . '��' . "" . '' . "" . '͕Q' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '}' . "" . '@' . "" . '' . "" . '' . "" . '' . "" . '�+�G^���� ����^+Vi��ت�`j�SV�V���] ��X^�����W},�$]�^��؏�O}n0(�K}���} �&}Ĉ$��@�}�}�^F@�pD��' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '}' . "" . '^' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '@' . "" . '' . "" . '' . "" . '�' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '@' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '}' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '}' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '�' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '@C��^����0� 9Eζ1��0$0w0��e' . "" . '�}���C�il���E(�� ܾ[�>��l5' . "" . '' . "" . '' . "" . '' . "" . 'J"�@�^K����A^�V݊Ci�i[p��' . "" . '����}WV�i���i�V����i#i�����' . "" . '' . "" . '' . "" . '' . "" . '@C}@}T�T��p�^��V��p�p��V ' . "" . '�0c�ؾ[���!ז׆�"�!���t��׳ק' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . ''); $this->assertEqual($entry->getText(), '1504 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Manual exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Standard'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 8); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(271); // Make $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'SONY'); $this->assertEqual($entry->getText(), 'SONY'); $entry = $ifd1->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'DSC-V1'); $this->assertEqual($entry->getText(), 'DSC-V1'); $entry = $ifd1->getEntry(274); // Orientation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'right - top'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); $entry = $ifd1->getEntry(306); // DateTime $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1089482993); $this->assertEqual($entry->getText(), '2004:07:10 18:09:53'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/sony-dsc-v1-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2); /* End of IFD $ifd1. */
function addExif($filename, $exifdata) { 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 first 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); // 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); } 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; } }
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c765uz.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 CORPORATION'); $this->assertEqual($entry->getText(), 'OLYMPUS CORPORATION'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'C765UZ'); $this->assertEqual($entry->getText(), 'C765UZ'); $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(), 'v777-76'); $this->assertEqual($entry->getText(), 'v777-76'); $entry = $ifd0->getEntry(306); // DateTime $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $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()), 32); $entry = $ifd0_0->getEntry(33434); // ExposureTime $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 10, 1 => 2000)); $this->assertEqual($entry->getText(), '1/200 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(), 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(), 64); $this->assertEqual($entry->getText(), '64'); $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(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), '' . "" . ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 34, 1 => 10)); $this->assertEqual($entry->getText(), '34/10'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 16); $this->assertEqual($entry->getText(), 'Flash did not fire, compulsory flash mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 109, 1 => 10)); $this->assertEqual($entry->getText(), '10.9 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'OLYMP' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'р' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'ь' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'є' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'ќ' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '4' . "" . '' . "" . '' . "" . '' . "" . '' . "" . ' ' . "" . ' ' . "" . '' . "" . '' . "" . 'L' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'ю' . "" . '' . "" . 'l' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'd' . "" . '' . "" . '' . "" . 'd' . "" . '' . "" . '' . "" . 'њ' . "" . '' . "" . 'ш' . "" . '' . "" . 'џџдўжџНџНџSX777' . "" . '' . "" . '' . "" . '[pictureInfo] Resolution=1 [Camera Info] Type=SX777' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'OLYMPUS DIGITAL CAMERA' . "" . 'џџџџџџџџџ4' . "" . '' . "" . '' . "" . '' . "" . 'џ' . "" . '' . "" . 'a1' . "" . '' . "" . 'у' . "" . '' . "" . ' ' . "" . '' . "" . 'ќ' . "" . '' . "" . '№' . "" . '' . "" . '№' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'd' . "" . 'Ч' . "" . '@' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '*' . "" . '' . "" . '' . "" . '' . "" . '*.' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '<' . "" . 'J' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'dќ' . "" . '' . "" . '' . "" . '' . "" . '""""""""""""""""""""Є~ы|Ё' . "" . '№Y' . "" . 'R' . "" . '' . "" . ' ' . "" . '' . "" . ' ' . "" . '' . "" . ' ' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'ЧoРh4' . "" . '' . "" . '/ с' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'эк' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '@' . "" . 'ИN' . "" . ' Dsода' . "" . '' . "" . 'э' . "" . '' . "" . '' . "" . 'DќSH СV' . "" . '' . "" . ' Ь7h8' . "" . '' . "" . 'џ )?&' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'Ї$уъз' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'wwww\' ' . "" . 'с' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'i' . "" . 'OvY' . "" . '$7' . "" . ')*ћю2' . "" . '' . "" . ' ' . "" . '6' . "" . 'nЁ$* R' . "" . '' . "" . ' n_' . "" . ''); $this->assertEqual($entry->getText(), '840 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ' '); $this->assertEqual($entry->getText(), ' '); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 2288); $this->assertEqual($entry->getText(), '2288'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 1712); $this->assertEqual($entry->getText(), '1712'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 100)); $this->assertEqual($entry->getText(), '0/100'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Portrait'); $entry = $ifd0_0->getEntry(41991); // GainControl $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41992); // Contrast $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41993); // Saturation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41994); // Sharpness $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c765uz-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data);
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/leica-d-lux.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(271); // Make $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'LEICA'); $this->assertEqual($entry->getText(), 'LEICA'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'D-LUX'); $this->assertEqual($entry->getText(), 'D-LUX'); $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(), 'Ver1.06'); $this->assertEqual($entry->getText(), 'Ver1.06'); $entry = $ifd0->getEntry(306); // DateTime $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1099994128); $this->assertEqual($entry->getText(), '2004:11:09 09:55:28'); $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(), 'PrintIM0250d ¬ Ä€ \'\'7\'°\'\'^\'‹\'Ë\'å\''); $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()), 37); $entry = $ifd0_0->getEntry(33434); // ExposureTime $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 10, 1 => 1000)); $this->assertEqual($entry->getText(), '1/100 sec.'); $entry = $ifd0_0->getEntry(33437); // FNumber $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 97, 1 => 10)); $this->assertEqual($entry->getText(), 'f/9.7'); $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(), 1099994128); $this->assertEqual($entry->getText(), '2004:11:09 09:55:28'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1099994128); $this->assertEqual($entry->getText(), '2004:11:09 09:55:28'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 21, 1 => 10)); $this->assertEqual($entry->getText(), '21/10'); $entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 6644, 1 => 1000)); $this->assertEqual($entry->getText(), '6644/1000 sec. (APEX: 10)'); $entry = $ifd0_0->getEntry(37378); // ApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 66, 1 => 10)); $this->assertEqual($entry->getText(), 'f/9.8'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 100)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 30, 1 => 10)); $this->assertEqual($entry->getText(), '30/10'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 3); $this->assertEqual($entry->getText(), 'Spot'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Daylight'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 24); $this->assertEqual($entry->getText(), 'Flash did not fire, auto mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 88, 1 => 10)); $this->assertEqual($entry->getText(), '8.8 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'LEICA0100 !r^"WBb6¹’¨ŒÜ KœÕ;D«l¸AF–Ž ST$AE§L( “Dà EP '); $this->assertEqual($entry->getText(), '256 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); $entry = $ifd0_0->getEntry(41495); // SensingMethod $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'One-chip color area sensor'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); $entry = $ifd0_0->getEntry(41730); // CFAPattern $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), '(undefined)'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0/10'); $entry = $ifd0_0->getEntry(41989); // FocalLengthIn35mmFilm $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 53); $this->assertEqual($entry->getText(), '53'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Standard'); $entry = $ifd0_0->getEntry(41991); // GainControl $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41992); // Contrast $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41993); // Saturation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41994); // Sharpness $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41996); // SubjectDistanceRange $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Close view'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 5); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); $entry = $ifd1->getEntry(531); // YCbCrPositioning $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'co-sited'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/leica-d-lux-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2); /* End of IFD $ifd1. */ $this->assertTrue(count(Pel::getExceptions()) == 0);
public function saveEdit($file, $name, $options = array(), $quality = 100) { // Check for request forgeries WFToken::checkToken() or die('Access to this resource is restricted'); // check for image editor access if ($this->checkAccess('image_editor', 1) === false) { JError::raiseError(403, 'Access to this resource is restricted'); } $browser = $this->getBrowser(); $filesystem = $browser->getFileSystem(); // check file self::validateImagePath($file); // clean temp $this->cleanEditorTmp($file, false); // check new name self::validateImagePath($name); $upload = JRequest::getVar('file', '', 'files', 'array'); // create a filesystem result object $result = new WFFileSystemResult(); if (isset($upload) && isset($upload['tmp_name']) && is_uploaded_file($upload['tmp_name'])) { $tmp = $upload['tmp_name']; self::validateImageFile($tmp); $exif = null; // get exif data from orignal file if (preg_match('#\\.jp(eg|g)$#i', basename($file)) && basename($file) == basename($name)) { // load exif classes require_once dirname(__FILE__) . '/pel/PelJpeg.php'; $src = WFUtility::makePath($filesystem->getBaseDir(), $file); $jpeg = new PelJpeg($src); $exif = $jpeg->getExif(); } $result = $filesystem->upload('multipart', trim($tmp), dirname($file), basename($name)); if ($result->state === true && $exif) { $pel = new PelDataWindow($result->path); if (PelJpeg::isValid($pel)) { $jpeg = new PelJpeg(); $jpeg->load($pel); $jpeg->setExif($exif); //$jpeg->saveFile($result->path); // write to file JFile::write($result->path, $jpeg->getBytes()); } } @unlink($tmp); } else { // set upload as false - JSON request $upload = false; $file = WFUtility::makePath($filesystem->getBaseDir(), $file); $dest = dirname($file) . '/' . basename($name); // get extension $ext = WFUtility::getExtension($dest); // load image class require_once dirname(__FILE__) . '/image/image.php'; // create image $image = new WFImage($file, $this->getParam('prefer_imagick', true)); foreach ($options as $filter) { if (isset($filter->task)) { $args = isset($filter->args) ? (array) $filter->args : array(); switch ($filter->task) { case 'resize': $w = $args[0]; $h = $args[1]; $image->resize($w, $h); break; case 'crop': $w = $args[0]; $h = $args[1]; $x = $args[2]; $y = $args[3]; $image->crop($w, $h, $x, $y); break; case 'rotate': $image->rotate(array_shift($args)); break; case 'flip': $image->flip(array_shift($args)); break; default: $image->filter($filter->task, $args); break; } } } // get image data $data = $image->toString($ext); // write to file if ($data) { $result->state = (bool) @JFile::write($dest, $data); } // set path $result->path = $dest; } if ($result->state === true) { // check if its a valid image if (@getimagesize($result->path) === false) { JFile::delete($result->path); throw new InvalidArgumentException('Invalid image file'); } else { $result->path = str_replace(WFUtility::cleanPath(JPATH_SITE), '', $result->path); $browser->setResult(WFUtility::cleanPath($result->path, '/'), 'files'); } } else { $browser->setResult($result->message || WFText::_('WF_IMGMANAGER_EXT_EDIT_SAVE_ERROR'), 'error'); } // set header and exit if ($upload) { header("Expires: Wed, 4 Apr 1984 13:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M_Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); die(json_encode($browser->getResult())); } // return to WFRequest return $browser->getResult(); }
function jpegToTest($name, PelJpeg $jpeg) { $exif = $jpeg->getExif(); println('$exif = %s->getExif();', $name); if ($exif == null) { println('$this->assertNull($exif);'); } else { jpegContentToTest('$exif', $exif); } }
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/olympus-c765uz.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 CORPORATION'); $this->assertEqual($entry->getText(), 'OLYMPUS CORPORATION'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'C765UZ'); $this->assertEqual($entry->getText(), 'C765UZ'); $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(), 'v777-76'); $this->assertEqual($entry->getText(), 'v777-76'); $entry = $ifd0->getEntry(306); // DateTime $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $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 => 2000)); $this->assertEqual($entry->getText(), '1/200 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(), 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(), 64); $this->assertEqual($entry->getText(), '64'); $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(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1090073972); $this->assertEqual($entry->getText(), '2004:07:17 14:19:32'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 34, 1 => 10)); $this->assertEqual($entry->getText(), '34/10'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 16); $this->assertEqual($entry->getText(), 'Flash did not fire, compulsory flash mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 109, 1 => 10)); $this->assertEqual($entry->getText(), '10.9 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'OLYMPрьєќ4 LюlddњшџџдўжџНџНџSX777[pictureInfo] Resolution=1 [Camera Info] Type=SX777OLYMPUS DIGITAL CAMERAџџџџџџџџџ4џa1у ќ№№dЧ@**.<Jdќ""""""""""""""""""""Є~ы|Ё№YR ЧoРh4/ сэк@ИN DsодаэDќSH СV Ь7h8џ )?&Ї$уъзwwww\' сiOvY$7)*ћю2 6nЁ$* R n_'); $this->assertEqual($entry->getText(), '840 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ' '); $this->assertEqual($entry->getText(), ' '); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 2288); $this->assertEqual($entry->getText(), '2288'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 1712); $this->assertEqual($entry->getText(), '1712'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 100)); $this->assertEqual($entry->getText(), '0/100'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Portrait'); $entry = $ifd0_0->getEntry(41991); // GainControl $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41992); // Contrast $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41993); // Saturation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41994); // Sharpness $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c765uz-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data);
/** * Check the existance of the files and generate everything needed on the fly * @access public * @param array $zoom * @param array $zoomTmp * @return array $zoom, $zoomTmp **/ public function proceedList($zoom, $zoomTmp) { if ($zoom['config']['cTimeCompare']) { $this->cTimeCompare($zoom); } $pic_list_array = $zoom['config']['pic_list_array']; $pic_list_data = $zoom['config']['pic_list_data']; if (!empty($pic_list_array) and !empty($pic_list_data)) { ////////////////////////////////////////////////////////////////////////////////////////////////////// //// Select the first picture if no zoomID /////////////////////////////////////////////////////////// //// passed over query string //////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// // zoomID must be a number (integer) > 0 !!! settype($_GET['zoomID'], 'int'); // Set the internal pointer of an array to its first element reset($pic_list_array); // You can also pass the filename, which has to exist in the $pic_list_array if (isset($_GET['zoomFile'])) { if (in_array($_GET['zoomFile'], $pic_list_array)) { $flipedArray = array_flip($pic_list_array); $_GET['zoomID'] = $flipedArray[$_GET['zoomFile']]; } } // If no zoomID passed or zoomID is not a key in picture array if (!$_GET['zoomID'] or !array_key_exists($_GET['zoomID'], $pic_list_array)) { // then select the first picture in defined array $_GET['zoomID'] = key($pic_list_array); } // Redefine the root path of the image if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); // Heuristic approach if (!is_dir($zoom['config']['picDir'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash('/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); if (is_dir($zoom['config']['picDir'])) { $zoom['config']['pic'] = ''; } else { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['installPath'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); if (is_dir($zoom['config']['picDir'])) { $zoom['config']['pic'] = $zoom['config']['installPath']; } } } } //////////////////////////////////////////////////////////////////////////////////////////////////////// //// Check if source file exists /////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////// // If for some reason there the original image does not exist, there is a problem, which could be solved // This may happen if you get images from the database entry, // but they do not exist in the filesystem because you may intentionally or unintentionally renamed them or whatever... // So we need to check the whole array if such an error occures if (!file_exists($zoom['config']['picDir'] . $pic_list_array[$_GET['zoomID']])) { // The passed zoomID is problematic! Unset it. unset($_GET['zoomID']); $pic_list_temp_array = $pic_list_array; $zoomTmp['errorImages'] = array(); // Loop through the $pic_list_array to find a picture that exists foreach ($pic_list_array as $k => $v) { if (isset($pic_list_data[$k]['path'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$k]['path'], 'add'), 'add'); } // If we have found an image, that exists :-) if (file_exists($zoom['config']['picDir'] . $pic_list_array[$v])) { // If we have not found an existing picture already if (!$zoomTmp['picFound']) { // Define $_GET['zoomID'] with the image key from $pic_list_array $_GET['zoomID'] = $k; // Define a var that tells the loop about a successful finding $zoomTmp['picFound'] = $k; } } else { $zoomTmp['errorImages'][$k] = $zoom['config']['picDir'] . $pic_list_array[$k]; //Patch: 20101-01-01 ($pic_list_array[$k] not $pic_list_array[$v]) // Remove this picture from the arrays unset($pic_list_temp_array[$k]); unset($pic_list_data[$k]); } } // If you have defined in zoomConfig.inc.php to show errors if ($zoom['config']['errors'] && !empty($zoomTmp['errorImages'])) { // Trigger message that lists missing images (with method drawZoomBox of axZmH.class.php) $zoomTmp['fileErrorTitle'] = "Error images missing"; // Display also the paths of images that can not be found foreach ($zoomTmp['errorImages'] as $k => $v) { $zoomTmp['fileErrorText'] .= "<li>{$v}</li> "; } // Compute what has been removed (not needed) /* $zoomTmp['fileError'] = array_diff($pic_list_array, $pic_list_temp_array); foreach ($zoomTmp['fileError'] as $k=>$v){$zoomTmp['fileErrorText'].="<li>$v</li> ";} */ $zoomTmp['fileErrorText'] = "<ul>" . $zoomTmp['fileErrorText'] . "</ul>"; $this->fileErrorDialog = "<script type=\"text/javascript\">jQuery.fn.axZm.zoomAlert('" . $zoomTmp['fileErrorText'] . "','" . $zoomTmp['fileErrorTitle'] . "',false);</script>"; } // Redefine the basic $pic_list_array with removed items $pic_list_array = $pic_list_temp_array; } // Store information in $zoom['config'] $zoom['config']['pic_list_array'] = $pic_list_array; $zoom['config']['pic_list_data'] = $pic_list_data; // Exif orientation if ($zoom['config']['exifAutoRotation'] && !isset($_GET['str']) && !isset($_GET['setHW']) && !defined('PHALANGER')) { $pelLib = false; // http://lsolesen.github.com/pel/ if (file_exists(dirname(__FILE__) . '/classes/pel/PelJpeg.php')) { $pelLib = true; require_once dirname(__FILE__) . '/classes/pel/PelDataWindow.php'; require_once dirname(__FILE__) . '/classes/pel/PelJpeg.php'; require_once dirname(__FILE__) . '/classes/pel/PelTiff.php'; } foreach ($pic_list_array as $k => $v) { if (strtolower($this->getl('.', $v)) == 'jpg' || strtolower($this->getl('.', $v)) == 'jpeg') { if (isset($pic_list_data[$k]['path'])) { $tempPicDir = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$k]['path'], 'add'), 'add'); } else { $tempPicDir = $zoom['config']['picDir']; } $aryEXIF = array(); $aryEXIF = exif_read_data($tempPicDir . $v); if (isset($aryEXIF["Orientation"]) && ($aryEXIF["Orientation"] == 6 || $aryEXIF["Orientation"] == 8)) { $angle = 0; if ($aryEXIF["Orientation"] == 6) { $angle = 270; } elseif ($aryEXIF["Orientation"] == 8) { $angle = 90; } if ($angle != 0) { if (is_writable($tempPicDir . $v)) { // Delete all already made tiles, thumbs etc. $this->removeAxZm($zoom, $v, array('In' => true, 'Th' => true, 'Ti' => true, 'gP' => true), false); // Save exif info if ($pelLib) { $sourceExifFile = new PelJpeg($tempPicDir . $v); $sourceExifInfo = $sourceExifFile->getExif(); } // Rotate $rotatedImage = $this->rotateImage($tempPicDir . $v, $angle); imagejpeg($rotatedImage, $tempPicDir . $v, 100); // Transfere EXIF information if ($pelLib) { $outputExifFile = new PelJpeg($tempPicDir . $v); if ($sourceExifInfo != null) { $outputExifFile->setExif($sourceExifInfo); file_put_contents($tempPicDir . $v, $outputExifFile->getBytes()); } // Reset the EXIF-tag "orientation" $this->exifOrientation($tempPicDir . $v, $tempPicDir . $v); } $pic_list_data[$k]['imgSize'] = $this->axZm->imageSize($tempPicDir . $v, $zoom['config']['im'], false); } else { if ($zoom['config']['errors']) { echo 'alert("' . $tempPicDir . $v . ' is not writable by PHP.");'; } } } } } $zoom['config']['pic_list_data'] = $pic_list_data; } } // By now we have generated and checked $pic_list_array and $pic_list_data // $_GET['zoomID'] is also checked and should exist if (isset($_GET['zoomID'])) { // Redefine the root path of the image if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); } //////////////////////////////////////////////////// //// Important for next code and zoomLoad.php !!!/// //////////////////////////////////////////////////// // 1. $zoom['config']['orgImgName'] // filename of the source image // 2. $zoom['config']['orgImgSize'] // imagesize of the source image // 3. $zoom['config']['smallImgName'] // filename of the initial image // 4. $zoom['config']['smallImgSize'] // imagesize of the initial image // 5. $zoom['config']['smallFileSize'] // filesize of thr initial image // 1. Filename of the source image $zoom['config']['orgImgName'] = $pic_list_array[$_GET['zoomID']]; // 2. Imagesize of the source image [array(0=>width, 1=>height)] // Do not replace it with $pic_list_data[$_GET['zoomID']]['imgSize'] // since this information will only be generated on load and we also need it for zooming (zoomLoad.php) $zoom['config']['orgImgSize'] = $this->axZm->imageSize($zoom['config']['picDir'] . $zoom['config']['orgImgName'], $zoom['config']['im'], false); // 3. Filename of the initial image // This image will be loaded first (without zoom) // Before it has to be resized with $zoom['config']['picDim'] and saved in $zoom['config']['thumbDir'] // e.g. imagename is abcdefgh.jpg, $zoom['config']['picDim'] = '600x400'; // It will be then saved as abcdefgh_600x400.jpg in $zoom['config']['thumbDir'] $zoom['config']['smallImgName'] = $this->composeFileName($pic_list_array[$_GET['zoomID']], $zoom['config']['picDim'], '_', $this->pngMod($zoom)); // 4. Make initial image on the fly and save it once // Only current displayed image will be made on the fly // Check if it exists first if (!file_exists($zoom['config']['thumbDir'] . $zoom['config']['smallImgName'])) { // Make first image $this->returnMakeFirstImage = $this->axZm->makeFirstImage($zoom, false); } else { if ($zoom['config']['mapOwnImage']) { if (!isset($zoom['config']['mapDir'])) { $zoom['config']['mapDir'] = $axZmH->checkSlash($zoom['config']['fpPP'] . $zoom['config']['mapPath'], 'add'); } if (!file_exists($zoom['config']['mapDir'] . $this->composeFileName($zoom['config']['orgImgName'], $zoom['config']['mapOwnImage'], '_', $this->pngMod($zoom)))) { $this->returnMakeFirstImage = $this->axZm->makeFirstImage($zoom, true); } } } // Imagesize of the initial image // We also need to know how big this initial image is, but only after it has been possibly made on the fly $zoom['config']['smallImgSize'] = $this->axZm->imageSize($zoom['config']['thumbDir'] . $zoom['config']['smallImgName'], $zoom['config']['im'], false); // 5. Filesize of the first image for internet connection speed test $zoom['config']['smallFileSize'] = filesize($zoom['config']['thumbDir'] . $zoom['config']['smallImgName']); // This will tell the javascript the dimensions of the initial picture if it is not already done and loaded via ajax // This happens if you load a new picture via javascript wich has not been "prepared" already. // In this case it will be prepared on the fly after calling it. The procedure can take a couple seconds. if (isset($_GET['setHW'])) { echo "<script type=\"text/javascript\">"; echo "\n\t\t\t\t\tjQuery.axZm['iw']=" . $this->ptj($zoom['config']['smallImgSize'][0]) . ";\n\t\t\t\t\tjQuery.axZm['ih']=" . $this->ptj($zoom['config']['smallImgSize'][1]) . ";\n\t\t\t\t\t"; echo "</script>"; if (!is_bool($this->returnMakeFirstImage)) { echo $this->returnMakeFirstImage; } // Do not exit here in order to make pyramid images or tiles on the fly too! // If $zoom['config']['pyrDialog'] OR $zoom['config']['gPyramidDialog'] is set to true // and tiles or image pyramid have to be generated, a "please wait" diolog will appear during this operation. // You can switch off this dialog by setting $zoom['config']['pyrDialog'] = false .... } // The following code will be executed only onece on window load... if (!isset($_GET['str'])) { if (!isset($_GET['setHW'])) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Get all initial image sizes for Image Gallery, but only on page load //////////////////////////////////////////// //// We will need to pass this parameters to and then from the gallery, when the user clicks on an different thumb /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// foreach ($pic_list_array as $k => $v) { $zoomTmp['smallImgNameTemp'] = $this->composeFileName($v, $zoom['config']['picDim'], '_', $this->pngMod($zoom)); // Since not all initial pictures could have been generated, check their existence first // Generation of all initial pictures on the fly during first page load could take to long. if (file_exists($zoom['config']['thumbDir'] . $zoomTmp['smallImgNameTemp'])) { $pic_list_data[$k]['thumbSize'] = $this->axZm->imageSize($zoom['config']['thumbDir'] . $zoomTmp['smallImgNameTemp'], $zoom['config']['im'], false); } else { $pic_list_data[$k]['thumbSize'] = false; } } // Store information $zoom['config']['pic_list_data'] = $pic_list_data; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Generate all thumbs for Image Gallery on the fly, /////////////////////////////////////////////////////////////// //// Depending on the number of pictures and it's sizes this may take a while... ///////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Added the possibility to not generate thumbs if (!isset($zoom['config']['galleryNoThumbs']) or $zoom['config']['galleryNoThumbs'] === false) { $this->returnMakeAllThumbs = $this->axZm->makeAllThumbs($zoom); } else { $this->returnMakeAllThumbs = false; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Image pyramid generation for selected zoomID, not all gallery list ////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($zoom['config']['gPyramid'] and $zoom['config']['gPyramidDir']) { // The subfolder name is the same as image name $zoomTmp['gPyramidPicDir'] = $zoom['config']['gPyramidDir'] . $this->getf('.', $zoom['config']['orgImgName']); // Check if pyramid images have been made already $zoomTmp['gPyramidPicDirExists'] = is_dir($zoomTmp['gPyramidPicDir']); // Make subfolder and generate the pyramid images, if they are not already made if (!$zoomTmp['gPyramidPicDirExists'] and !file_exists($zoom['config']['picDir'] . $this->getf('.', $zoom['config']['orgImgName']) . '.txt')) { $this->returnMakeZoomTiles = $this->axZm->gPyramid($zoom); if (isset($_GET['setHW']) and !is_bool($this->returnMakeZoomTiles)) { echo $this->returnMakeZoomTiles; } } elseif ($zoomTmp['gPyramidPicDirExists'] and $zoom['config']['gPyramidOverwrite'] and is_int($zoom['config']['gPyramidTime']) and strlen($zoom['config']['gPyramidTimeDim']) and !file_exists($zoom['config']['picDir'] . $this->getf('.', $zoom['config']['orgImgName']) . '.txt')) { $this->returnMakeZoomTiles = $this->axZm->gPyramid($zoom); if (isset($_GET['setHW']) and !is_bool($this->returnMakeZoomTiles)) { echo $this->returnMakeZoomTiles; } } // Changes chmod of all pyramid directories if ($zoom['config']['gPyramidChmodAll']) { $this->chmodAllDir($zoom['config']['gPyramidDir'], $zoom['config']['gPyramidChmod']); } } //////////////////////////////////////////////////////////////////////// /// Image tiles generation for selected zoomID, not all gallery list /// //////////////////////////////////////////////////////////////////////// if ($zoom['config']['pyrTiles'] and $zoom['config']['pyrTilesDir']) { $zoomTmp['thisTilesPicDir'] = $zoom['config']['pyrTilesDir'] . $this->getf('.', $zoom['config']['orgImgName']); if ($zoom['config']['orgImgSize'][0] >= $zoom['config']['tileSize'] or $zoom['config']['orgImgSize'][1] >= $zoom['config']['tileSize']) { $this->returnMakeZoomTiles = $this->axZm->zC($zoom, false); if (!file_exists($zoomTmp['thisTilesPicDir'] . '/0-0-0.' . $this->pngMod($zoom)) and !file_exists($zoom['config']['picDir'] . $this->getf('.', $zoom['config']['orgImgName']) . '.txt')) { $this->returnMakeZoomTiles = $this->axZm->makeZoomTiles($zoom); } if (isset($_GET['setHW']) and !is_bool($this->returnMakeZoomTiles) and $this->returnMakeZoomTiles) { echo $this->returnMakeZoomTiles; } } // Changes chmod matched with the config if ($zoom['config']['pyrChmodAll']) { $this->chmodAllDir($zoom['config']['pyrTilesDir'], $zoom['config']['pyrChmod']); } } ////////////////////////////////////////////////////////////////////////////////// // Generate code (an array) for the gallery, which will be passed to javascript // ////////////////////////////////////////////////////////////////////////////////// if (!isset($_GET['setHW'])) { // && ($zoom['config']['useGallery'] OR $zoom['config']['useFullGallery'] OR $zoom['config']['useHorGallery'] OR $zoom['config']['galleryNavi']) foreach ($pic_list_data as $k => $v) { $zoom['config']['galArray'][$k]['img'] = $v['fileName']; // Filename of the image $zoom['config']['galArray'][$k]['ow'] = $v['imgSize'][0]; // Width of original pic $zoom['config']['galArray'][$k]['oh'] = $v['imgSize'][1]; // Height of original pic $zoom['config']['galArray'][$k]['iw'] = $v['thumbSize'][0]; // Width of initial pic $zoom['config']['galArray'][$k]['ih'] = $v['thumbSize'][1]; // Height of initial pic $zoom['config']['galArray'][$k]['tD'] = $v['thumbDescr']; // Description under the thumb in the gallery $zoom['config']['galArray'][$k]['fD'] = $v['fullDescr']; // Full Description //$zoom['config']['galArray'][$k]['fT'] = $this->getl('.', $pic_list_array[$k]); //$zoom['config']['galArray'][$k]['fB'] = $this->getf('.', $pic_list_array[$k]); // Ver. 4.0 $zoom['config']['galArray'][$k]['mf'] = false; if ($zoom['config']['useMap'] && $zoom['config']['mapOwnImage'] && $zoom['config']['mapDir']) { $ownImageSize = explode('x', $zoom['config']['mapOwnImage']); $ownImageName = $this->composeFileName($v['fileName'], $ownImageSize[0] . 'x' . $ownImageSize[1], '_', $this->pngMod($zoom)); if (!file_exists($zoom['config']['mapDir'] . $ownImageName)) { $zoom['config']['galArray'][$k]['mf'] = true; } } if (isset($v['path'])) { // Note: this is absolute path to the image now $zoom['config']['galArray'][$k]['ph'] = $this->checkSlash($zoom['config']['pic'] . '/' . $v['path'], 'add'); // Image Path } // Check, whether pyramid or tiles have to be generated if ($zoom['config']['gPyramid']) { if (is_dir($zoom['config']['gPyramidDir'] . $this->getf('.', $v['fileName']))) { //$zoom['config']['galArray'][$k][9]=false; $zoom['config']['galArray'][$k]['mk'] = false; } else { $zoom['config']['galArray'][$k]['mk'] = 'gP'; } } elseif ($zoom['config']['pyrTiles']) { if ($v['imgSize'][0] < $zoom['config']['tileSize'] && $v['imgSize'][1] < $zoom['config']['tileSize'] or file_exists($zoom['config']['pyrTilesDir'] . $this->getf('.', $v['fileName']) . '/0-0-0.' . $this->pngMod($zoom))) { $zoom['config']['galArray'][$k]['mk'] = false; if ($zoom['config']['pyrAutoDetect']) { $thisTileSize = $this->axZm->imageSize($zoom['config']['pyrTilesDir'] . $this->getf('.', $v['fileName']) . '/0-0-0.' . $this->pngMod($zoom), $zoom['config']['im'], false); $zoom['config']['galArray'][$k]['ts'] = intval(max($thisTileSize[0], $thisTileSize[1])); } } else { $zoom['config']['galArray'][$k]['mk'] = 'tL'; } } else { $zoom['config']['galArray'][$k]['mk'] = false; } } // END: foreach ($pic_list_data as $k=>$v){ } // END: if (!isset($_GET['setHW'])){ } // END: if (!isset($_GET['str'])) if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $zoom['config']['pic'] = $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'); } } // END: if ($_GET['zoomID']) } else { unset($_GET['zoomID']); } return array($zoom, $zoomTmp); }
/** * 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) { $pelJpegLib = dirname(__FILE__) . '/../pel/src/PelJpeg.php'; // Linking to pel library will break MIT license // Make the EXIF copy optional if (file_exists($pelJpegLib)) { // Make sure to suppress strict warning thrown by PEL require_once $pelJpegLib; $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; } } return file_get_contents($cacheFilePath); }
/** * Generuje miniaturę i zapisuje do exifa * @param <type> $fullpath */ public function generujMiniature($fullpath) { // include_once('C:\xampp\php\PEAR\PelJpeg.php'); // include_once('C:\xampp\php\PEAR\PelExif.php'); // include_once('C:\xampp\php\PEAR\PelIfd.php'); $jpeg = new PelJpeg($fullpath); $exif = $jpeg->getExif(); //Jeżeli zdjęcie nie posiada exifa if (!$exif) { //Utworzenie kontera exif $pelexif = new PelExif(); //Dodanie obiektu PelTiff i PelIfd $tiff = new PelTiff(); $ifd0 = new PelIfd(PelIfd::IFD0); $tiff->setIfd($ifd0); $pelexif->setTiff($tiff); //Dodanie obiektów do zdjęcia $jpeg->setExif($pelexif); } $exif = $jpeg->getExif(); $tiff = $exif->getTiff(); $ifd0 = $tiff->getIfd(); $ifd1 = $ifd0->getNextIfd(); //tworzenie miniatury jeżli nie istnieje (nie ma IFD1) if (!$ifd1) { $ifd1 = new PelIfd(1); //point ifd0 to the new ifd1 (or else ifd1 will not be read) $ifd0->setNextIfd($ifd1); //create image resource of original $original = ImageCreateFromString($jpeg->getBytes()); $orig_w = imagesx($original); $orig_h = imagesy($original); $wmax = 160; $hmax = 120; if ($orig_w > $wmax || $orig_h > $hmax) { $thumb_w = $wmax; $thumb_h = $hmax; if ($thumb_w / $orig_w * $orig_h > $thumb_h) { $thumb_w = round($thumb_h * $orig_w / $orig_h); } else { $thumb_h = round($thumb_w * $orig_h / $orig_w); } } else { # only set the thumb's size if the original is larger than 'wmax'x'hmax' $thumb_w = $orig_w; $thumb_h = $orig_h; } # create image resource with thumbnail sizing $thumb = imagecreatetruecolor($thumb_w, $thumb_h); ## Resize original and copy to the blank thumb resource imagecopyresampled($thumb, $original, 0, 0, 0, 0, $thumb_w, $thumb_h, $orig_w, $orig_h); # 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 $outpath = $fullpath; # overwrite original jpg file file_put_contents($outpath, $jpeg->getBytes()); # write everything to output filename } } }
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/nikon-e5000.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()), 9); $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(), 'NIKON'); $this->assertEqual($entry->getText(), 'NIKON'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'E5000'); $this->assertEqual($entry->getText(), 'E5000'); $entry = $ifd0->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 300, 1 => 1)); $this->assertEqual($entry->getText(), '300/1'); $entry = $ifd0->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 300, 1 => 1)); $this->assertEqual($entry->getText(), '300/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(), 'E5000v1.6'); $this->assertEqual($entry->getText(), 'E5000v1.6'); $entry = $ifd0->getEntry(306); // DateTime $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1021992832); $this->assertEqual($entry->getText(), '2002:05:21 14:53:52'); $entry = $ifd0->getEntry(531); // YCbCrPositioning $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'centered'); /* Sub IFDs of $ifd0. */ $this->assertEqual(count($ifd0->getSubIfds()), 2); $ifd0_0 = $ifd0->getSubIfd(2); // IFD Exif $this->assertIsA($ifd0_0, 'PelIfd'); /* Start of IDF $ifd0_0. */ $this->assertEqual(count($ifd0_0->getEntries()), 22); $entry = $ifd0_0->getEntry(33434); // ExposureTime $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 1642036, 1 => 100000000)); $this->assertEqual($entry->getText(), '1/60 sec.'); $entry = $ifd0_0->getEntry(33437); // FNumber $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 28, 1 => 10)); $this->assertEqual($entry->getText(), 'f/2.8'); $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.1); $this->assertEqual($entry->getText(), 'Exif Version 2.1'); $entry = $ifd0_0->getEntry(36867); // DateTimeOriginal $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1021992832); $this->assertEqual($entry->getText(), '2002:05:21 14:53:52'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1021992832); $this->assertEqual($entry->getText(), '2002:05:21 14:53:52'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 3, 1 => 1)); $this->assertEqual($entry->getText(), '3/1'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Flash did not fire.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 71, 1 => 10)); $this->assertEqual($entry->getText(), '7.1 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), '�� ��� � ���� �"�*��2��D�JrCOLORFINE AUTO 1AUTO AF-C :NORMAL �"�AUTO AUTO OFF OFF PrintIM0100 ^ � � \'\'�\'�\'\'^\'�\'�\'�\''); $this->assertEqual($entry->getText(), '604 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ' '); $this->assertEqual($entry->getText(), ' '); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 1600); $this->assertEqual($entry->getText(), '1600'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 1200); $this->assertEqual($entry->getText(), '1200'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $ifd0_1 = $ifd0->getSubIfd(3); // IFD GPS $this->assertIsA($ifd0_1, 'PelIfd'); /* Start of IDF $ifd0_1. */ $this->assertEqual(count($ifd0_1->getEntries()), 0); /* Sub IFDs of $ifd0_1. */ $this->assertEqual(count($ifd0_1->getSubIfds()), 0); $this->assertEqual($ifd0_1->getThumbnailData(), ''); /* Next IFD. */ $ifd0_2 = $ifd0_1->getNextIfd(); $this->assertNull($ifd0_2); /* End of IFD $ifd0_1. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/nikon-e5000-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2);
/** * 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); }
$("#debug").animate({"height": "toggle"}, { duration: 0 }); } //]]> </script> <title>EXIF to RDF Prototype</title> </head> <body> <div id="container"> <h1>exif2rdf prototype</h1> <img src="<?php echo $IMG_SRC; ?> " alt="Sample image"/> <?php $jpeg = new PelJpeg($IMG_SRC); $exif = $jpeg->getExif(); if ($exif != null) { $tiff = $exif->getTiff(); $ifd0 = $tiff->getIfd(); $exif2 = $ifd0->getSubIfd(PelIfd::EXIF); $ifd1 = $ifd0->getNextIfd(); // Image File Directory (IFD) $rapModel->add(new Statement($rapImage, new Resource(EXIF_NS . "#IFD"), new Literal($ifd1))); // Loop through PEL tags foreach ($PEL_TAGS_VALUE as $tagname => $peltag) { $data = $ifd0->getEntry($peltag); if ($data != null) { $exifdata[$tagname] = $data; } } ?>
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 $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(), false); $this->assertEqual($entry->getText(), '0000:00:00 00:00:00'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), false); $this->assertEqual($entry->getText(), '0000:00:00 00:00:00'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 10)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 28, 1 => 10)); $this->assertEqual($entry->getText(), '28/10'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37384); // LightSource $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Unknown'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 16); $this->assertEqual($entry->getText(), 'Flash did not fire, compulsory flash mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 213, 1 => 10)); $this->assertEqual($entry->getText(), '21.3 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), 'OLYMP�����4 B�bdd�d 8ISX558[pictureInfo] Resolution=1 [Camera Info] Type=SX558OLYMPUS DIGITAL CAMERA���������1��H���UU�1������J@gg�I˦��������������������a1v?�Y�0� ��n��r�[R 2 H�dx 2B@d* '); $this->assertEqual($entry->getText(), '600 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ' '); $this->assertEqual($entry->getText(), ' '); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryLong'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41729); // SceneType $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Directly photographed'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Manual white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 100)); $this->assertEqual($entry->getText(), '0/100'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Standard'); $entry = $ifd0_0->getEntry(41991); // GainControl $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41992); // Contrast $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41993); // Saturation $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); $entry = $ifd0_0->getEntry(41994); // Sharpness $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 2); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 72, 1 => 1)); $this->assertEqual($entry->getText(), '72/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/olympus-c5050z-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2);
println(' input the input filename, a JPEG image.'); println(' output filename for saving the changed image.'); println(' scale scale factor, say 0.5 to resize to half the ' . 'original size.'); exit(1); } /* The input file is now loaded into a PelJpeg object. */ println('Reading file "%s".', $input); $input_jpeg = new PelJpeg($input); /* The input image is already loaded, so we can reuse the bytes stored * in $input_jpeg when creating the Image resource. */ $original = ImageCreateFromString($input_jpeg->getBytes()); $original_w = ImagesX($original); $original_h = ImagesY($original); $scaled_w = $original_w * $scale; $scaled_h = $original_h * $scale; /* Now create the scaled image. */ $scaled = ImageCreateTrueColor($scaled_w, $scaled_h); ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h); /* We want the raw JPEG data from $scaled. Luckily, one can create a * PelJpeg object from an image resource directly: */ $output_jpeg = new PelJpeg($scaled); /* Retrieve the original Exif data in $jpeg (if any). */ $exif = $input_jpeg->getExif(); /* If no Exif data was present, then $exif is null. */ if ($exif != null) { $output_jpeg->setExif($exif); } /* We can now save the scaled image. */ println('Writing file "%s".', $output); file_put_contents($output, $output_jpeg->getBytes()); /* The End. */
println('Optional arguments:'); println(' -d turn debug output on.'); println('Mandatory arguments:'); println(' file ... one or more file names.'); exit(1); } /* We typically need lots of RAM to parse TIFF images since they tend * to be big and uncompressed. */ ini_set('memory_limit', '32M'); foreach ($argv as $file) { println('Reading file "%s".', $file); $data = new PelDataWindow(file_get_contents($file)); if (PelJpeg::isValid($data)) { $jpeg = new PelJpeg(); $jpeg->load($data); $app1 = $jpeg->getExif(); if ($app1 == null) { println('Skipping %s because no APP1 section was found.', $file); continue; } $tiff = $app1->getTiff(); } elseif (PelTiff::isValid($data)) { $tiff = new PelTiff($data); } else { println('Unrecognized image format! Skipping.'); continue; } $ifd0 = $tiff->getIfd(); $entry = $ifd0->getEntry(PelTag::DATE_TIME); if ($entry == null) { println('Skipping %s because no DATE_TIME tag was found.', $file);
/** * This method calculates the image and delivers it to the client. * * @param $folder * @param $file * @param $width * @param $height * @param $mode */ public function resize($folder, $file, $width = -1, $height = -1, $mode = 'nocrop') { $jpeg_orientation_translation = array(1 => 0, 2 => 0, 3 => 180, 4 => 0, 5 => 0, 6 => -90, 7 => 0, 8 => 90); /** * @var JApplicationSite $app */ $app = JFactory::getApplication(); $params = $app->getParams(); if (strcmp($mode, 'full') == 0) { $mode = 'nocrop'; $width = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH; $height = COM_EVENTGALLERY_IMAGE_ORIGINAL_MAX_WIDTH; } if ($height > $width) { $width = $height; } $sizeSet = new EventgalleryHelpersSizeset(); $saveAsSize = $sizeSet->getMatchingSize($width); $file = STR_REPLACE("\\.\\.", "", $file); $folder = STR_REPLACE("\\.\\.", "", $folder); $width = STR_REPLACE("\\.\\.", "", $width); $mode = STR_REPLACE("\\.\\.", "", $mode); $file = STR_REPLACE("/", "", $file); $folder = STR_REPLACE("/", "", $folder); $width = STR_REPLACE("/", "", $width); $mode = STR_REPLACE("/", "", $mode); $file = STR_REPLACE("\\", "", $file); $folder = STR_REPLACE("\\", "", $folder); $width = STR_REPLACE("\\", "", $width); $mode = STR_REPLACE("\\", "", $mode); $basedir = COM_EVENTGALLERY_IMAGE_FOLDER_PATH; $sourcedir = $basedir . $folder; $cachebasedir = COM_EVENTGALLERY_IMAGE_CACHE_PATH; $cachedir = $cachebasedir . $folder; $cachedir_thumbs = $cachebasedir . $folder; if (!is_dir(JPATH_CACHE)) { //mkdir($cachebasedir, 0777); mkdir(JPATH_CACHE); } if (!is_dir($cachebasedir)) { //mkdir($cachebasedir, 0777); mkdir($cachebasedir); } if (!is_dir($cachedir)) { //mkdir($cachedir, 0777); mkdir($cachedir); } if (!is_dir($cachedir_thumbs)) { //mkdir($cachedir_thumbs, 0777); mkdir($cachedir_thumbs); } $image_file = $sourcedir . DIRECTORY_SEPARATOR . $file; $image_thumb_file = $cachedir_thumbs . DIRECTORY_SEPARATOR . $mode . $saveAsSize . $file; //$last_modified = gmdate('D, d M Y H:i:s T', filemtime ($image_file)); $last_modified = gmdate('D, d M Y H:i:s T', mktime(0, 0, 0, 1, 1, 2100)); #echo "<br>".$image_thumb_file."<br>"; $debug = false; if ($debug || !file_exists($image_thumb_file)) { $ext = pathinfo($image_file, PATHINFO_EXTENSION); $input_jpeg = null; $exif = null; if (strtolower($ext) == "gif") { if (!($im_original = imagecreatefromgif($image_file))) { echo "Error opening {$image_file}!"; exit; } } else { if (strtolower($ext) == "jpg" || strtolower($ext) == "jpeg") { // try to use PEL first. If things fail, use the php internal method to get the JPEG try { $input_jpeg = new PelJpeg($image_file); /* Retrieve the original Exif data in $jpeg (if any). */ $exif = $input_jpeg->getExif(); /* The input image is already loaded, so we can reuse the bytes stored * in $input_jpeg when creating the Image resource. */ if (!($im_original = ImageCreateFromString($input_jpeg->getBytes()))) { echo "Error opening {$image_file}!"; exit; } } catch (Exception $e) { if (!($im_original = imagecreatefromjpeg($image_file))) { echo "Error opening {$image_file}!"; exit; } } } else { if (strtolower($ext) == "png") { if (!($im_original = imagecreatefrompng($image_file))) { echo "Error opening {$image_file}!"; exit; } } else { die("{$ext} not supported"); } } } if ($params->get('use_autorotate', 1) == 1 && $exif != NULL) { $tiff = $exif->getTiff(); $ifd0 = $tiff->getIfd(); $orientation = $ifd0->getEntry(PelTag::ORIENTATION); if ($orientation != null) { $im_original = imagerotate($im_original, $jpeg_orientation_translation[$orientation->getValue()], 0); $orientation->setValue(1); } } $orig_width = imagesx($im_original); $orig_height = imagesy($im_original); $orig_ratio = imagesx($im_original) / imagesy($im_original); $sizeCalc = new EventgalleryHelpersSizecalculator($orig_width, $orig_height, $width, strcmp('crop', $mode) == 0); $height = $sizeCalc->getHeight(); $width = $sizeCalc->getWidth(); //print_r($sizeCalc); // create canvas/border image //adjust height to not enlarge images if ($width > $orig_width) { $width = $orig_width; } if ($height > $orig_height) { $height = $orig_height; } if (strcmp('crop', $mode) != 0) { $canvasWidth = $width; $canvasHeight = ceil($width / $orig_ratio); if ($canvasHeight > $height) { $canvasHeight = $height; $canvasWidth = ceil($height * $orig_ratio); } $width = $canvasWidth; $height = $canvasHeight; } else { $height = $width; } $isOriginalSize = false; if ($height == $orig_height && $width == $orig_width) { $isOriginalSize = true; } /** * Do not recalculate the image if we don't need to resize it. */ if ($isOriginalSize && $params->get('use_sharpening_for_originalsize', 1) == 0) { $im_output = $im_original; } else { $im_output = imagecreatetruecolor($width, $height); $resize_faktor = $orig_height / $height; $new_height = $height; $new_width = $orig_width / $resize_faktor; if ($new_width < $width) { $resize_faktor = $orig_width / $width; $new_width = $width; $new_height = $orig_height / $resize_faktor; } imagecopyresampled($im_output, $im_original, $width / 2 - $new_width / 2, $height / 2 - $new_height / 2, 0, 0, $new_width, $new_height, $orig_width, $orig_height); $use_sharpening = $params->get('use_sharpening', 1); if ($use_sharpening == 1) { // configure the sharpening $stringSharpenMatrix = $params->get('image_sharpenMatrix', '[[-1,-1,-1],[-1,16,-1],[-1,-1,-1]]'); $sharpenMatrix = json_decode($stringSharpenMatrix); if (null == $sharpenMatrix || count($sharpenMatrix) != 3) { $sharpenMatrix = array(array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1)); } $divisor = array_sum(array_map('array_sum', $sharpenMatrix)); $offset = 0; if (function_exists('imageconvolution')) { if (version_compare(phpversion(), '5.5.9', '=')) { $this->imageconvolution($im_output, $sharpenMatrix, $divisor, $offset); } else { imageconvolution($im_output, $sharpenMatrix, $divisor, $offset); } } } } /** * @var EventgalleryLibraryManagerFolder $folderMgr * @var EventgalleryLibraryFolder $folder */ $folderMgr = EventgalleryLibraryManagerFolder::getInstance(); $folder = $folderMgr->getFolder($folder); $watermark = $folder->getWatermark(); // load default watermark if (null == $watermark || !$watermark->isPublished()) { /** * @var EventgalleryLibraryManagerWatermark $watermarkMgr * @var EventgalleryLibraryWatermark $watermark */ $watermarkMgr = EventgalleryLibraryManagerWatermark::getInstance(); $watermark = $watermarkMgr->getDefaultWatermark(); } if (null != $watermark && $watermark->isPublished()) { $watermark->addWatermark($im_output); } $image_quality = $params->get('image_quality', 85); if ($input_jpeg != null) { Pel::setJPEGQuality($image_quality); /* We want the raw JPEG data from $scaled. Luckily, one can create a * PelJpeg object from an image resource directly: */ $output_jpeg = new PelJpeg($im_output); /* If no Exif data was present, then $exif is null. */ if ($exif != null) { $output_jpeg->setExif($exif); } /* We can now save the scaled image. */ $writeSuccess = true; $output_jpeg->saveFile($image_thumb_file); } else { $writeSuccess = imagejpeg($im_output, $image_thumb_file, $image_quality); if (!$writeSuccess) { die("Unable to write to file {$image_thumb_file}"); } } if (!$writeSuccess) { die("Unable to write to file {$image_thumb_file}"); } $time = time() + 315360000; touch($image_thumb_file, $time); // add the ICC profile try { $o = new JPEG_ICC(); $o->LoadFromJPEG($image_file); $o->SaveToJPEG($image_thumb_file); } catch (Exception $e) { } } $mime = ($mime = getimagesize($image_thumb_file)) ? $mime['mime'] : $mime; $size = filesize($image_thumb_file); $fp = fopen($image_thumb_file, "rb"); if (!($mime && $size && $fp)) { // Error. return; } if (!$debug) { header("Content-Type: " . $mime); header("Content-Length: " . $size); header("Last-Modified: {$last_modified}"); } fpassthru($fp); die; //$app->close(); }
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/canon-powershot-s60.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()), 8); $entry = $ifd0->getEntry(271); // Make $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'Canon'); $this->assertEqual($entry->getText(), 'Canon'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'Canon PowerShot S60'); $this->assertEqual($entry->getText(), 'Canon PowerShot S60'); $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 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd0->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/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(), 1097316018); $this->assertEqual($entry->getText(), '2004:10:09 10:00:18'); $entry = $ifd0->getEntry(531); // YCbCrPositioning $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'centered'); /* 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 => 8)); $this->assertEqual($entry->getText(), '1/8 sec.'); $entry = $ifd0_0->getEntry(33437); // FNumber $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 53, 1 => 10)); $this->assertEqual($entry->getText(), 'f/5.3'); $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(), 1097316018); $this->assertEqual($entry->getText(), '2004:10:09 10:00:18'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1097316018); $this->assertEqual($entry->getText(), '2004:10:09 10:00:18'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 96, 1 => 32)); $this->assertEqual($entry->getText(), '96/32 sec. (APEX: 2)'); $entry = $ifd0_0->getEntry(37378); // ApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 154, 1 => 32)); $this->assertEqual($entry->getText(), 'f/5.3'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 0, 1 => 3)); $this->assertEqual($entry->getText(), '0.0'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 154, 1 => 32)); $this->assertEqual($entry->getText(), '154/32'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 16); $this->assertEqual($entry->getText(), 'Flash did not fire, compulsory flash mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 662, 1 => 32)); $this->assertEqual($entry->getText(), '20.7 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), '.���"�0<D| ��iB �9�� $�\\@����� ������5 ���"�D �6�`j�`� �� ��\',��,��,��������*** IMG:PowerShot S60 JPEGFirmware Version 1.00Q ��H ||}z�|�zDX� �� t�%�*��II*�'); $this->assertEqual($entry->getText(), '904 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), ''); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); $entry = $ifd0_0->getEntry(41486); // FocalPlaneXResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 640000, 1 => 283)); $this->assertEqual($entry->getText(), '640000/283'); $entry = $ifd0_0->getEntry(41487); // FocalPlaneYResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 480000, 1 => 212)); $this->assertEqual($entry->getText(), '480000/212'); $entry = $ifd0_0->getEntry(41488); // FocalPlaneResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); $entry = $ifd0_0->getEntry(41495); // SensingMethod $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'One-chip color area sensor'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Auto white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2592, 1 => 2592)); $this->assertEqual($entry->getText(), '2592/2592'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Standard'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 4); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); $entry = $ifd0_0_0->getEntry(4097); // RelatedImageWidth $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0_0->getEntry(4098); // RelatedImageLength $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/canon-powershot-s60-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2); /* End of IFD $ifd1. */ $this->assertTrue(count(Pel::getExceptions()) == 0);
/** * 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-0.9.2/src/PelJpeg.php'); $jpeg = new PelJpeg($this->source->fullPath()); $exif = $jpeg->getExif(); if ($exif) { $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); }
function testRead() { Pel::clearExceptions(); Pel::setStrictParsing(false); $jpeg = new PelJpeg(dirname(__FILE__) . '/canon-ixus-ii.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()), 8); $entry = $ifd0->getEntry(271); // Make $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'Canon'); $this->assertEqual($entry->getText(), 'Canon'); $entry = $ifd0->getEntry(272); // Model $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'Canon DIGITAL IXUS II'); $this->assertEqual($entry->getText(), 'Canon DIGITAL IXUS II'); $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 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd0->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/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(), 1089488628); $this->assertEqual($entry->getText(), '2004:07:10 19:43:48'); $entry = $ifd0->getEntry(531); // YCbCrPositioning $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'centered'); /* 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 => 30)); $this->assertEqual($entry->getText(), '1/30 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(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(), 1089488628); $this->assertEqual($entry->getText(), '2004:07:10 19:43:48'); $entry = $ifd0_0->getEntry(36868); // DateTimeDigitized $this->assertIsA($entry, 'PelEntryTime'); $this->assertEqual($entry->getValue(), 1089488628); $this->assertEqual($entry->getText(), '2004:07:10 19:43:48'); $entry = $ifd0_0->getEntry(37121); // ComponentsConfiguration $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'Y Cb Cr -'); $entry = $ifd0_0->getEntry(37122); // CompressedBitsPerPixel $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2, 1 => 1)); $this->assertEqual($entry->getText(), '2/1'); $entry = $ifd0_0->getEntry(37377); // ShutterSpeedValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => 157, 1 => 32)); $this->assertEqual($entry->getText(), '157/32 sec. (APEX: 5)'); $entry = $ifd0_0->getEntry(37378); // ApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 107, 1 => 32)); $this->assertEqual($entry->getText(), 'f/3.2'); $entry = $ifd0_0->getEntry(37380); // ExposureBiasValue $this->assertIsA($entry, 'PelEntrySRational'); $this->assertEqual($entry->getValue(), array(0 => -1, 1 => 3)); $this->assertEqual($entry->getText(), '-0.3'); $entry = $ifd0_0->getEntry(37381); // MaxApertureValue $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 107, 1 => 32)); $this->assertEqual($entry->getText(), '107/32'); $entry = $ifd0_0->getEntry(37383); // MeteringMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 5); $this->assertEqual($entry->getText(), 'Pattern'); $entry = $ifd0_0->getEntry(37385); // Flash $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 16); $this->assertEqual($entry->getText(), 'Flash did not fire, compulsory flash mode.'); $entry = $ifd0_0->getEntry(37386); // FocalLength $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 215, 1 => 32)); $this->assertEqual($entry->getText(), '6.7 mm'); $entry = $ifd0_0->getEntry(37500); // MakerNote $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), '.\\��"� X `�|W �# "�\\@��Z� j�������D��k���6j��+ ��q*��r��r��r������000IMG:DIGITAL IXUS II JPEGFirmware Version 1.00D ���������@�� �� m���l'); $this->assertEqual($entry->getText(), '590 bytes unknown MakerNote data'); $entry = $ifd0_0->getEntry(37510); // UserComment $this->assertIsA($entry, 'PelEntryUserComment'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), ''); $entry = $ifd0_0->getEntry(40960); // FlashPixVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'FlashPix Version 1.0'); $entry = $ifd0_0->getEntry(40961); // ColorSpace $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'sRGB'); $entry = $ifd0_0->getEntry(40962); // PixelXDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0->getEntry(40963); // PixelYDimension $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); $entry = $ifd0_0->getEntry(41486); // FocalPlaneXResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 640000, 1 => 208)); $this->assertEqual($entry->getText(), '640000/208'); $entry = $ifd0_0->getEntry(41487); // FocalPlaneYResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 480000, 1 => 156)); $this->assertEqual($entry->getText(), '480000/156'); $entry = $ifd0_0->getEntry(41488); // FocalPlaneResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); $entry = $ifd0_0->getEntry(41495); // SensingMethod $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'One-chip color area sensor'); $entry = $ifd0_0->getEntry(41728); // FileSource $this->assertIsA($entry, 'PelEntryUndefined'); $this->assertEqual($entry->getValue(), ''); $this->assertEqual($entry->getText(), 'DSC'); $entry = $ifd0_0->getEntry(41985); // CustomRendered $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Normal process'); $entry = $ifd0_0->getEntry(41986); // ExposureMode $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Manual exposure'); $entry = $ifd0_0->getEntry(41987); // WhiteBalance $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Manual white balance'); $entry = $ifd0_0->getEntry(41988); // DigitalZoomRatio $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 2048, 1 => 2048)); $this->assertEqual($entry->getText(), '2048/2048'); $entry = $ifd0_0->getEntry(41990); // SceneCaptureType $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 0); $this->assertEqual($entry->getText(), 'Standard'); /* Sub IFDs of $ifd0_0. */ $this->assertEqual(count($ifd0_0->getSubIfds()), 1); $ifd0_0_0 = $ifd0_0->getSubIfd(4); // IFD Interoperability $this->assertIsA($ifd0_0_0, 'PelIfd'); /* Start of IDF $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getEntries()), 4); $entry = $ifd0_0_0->getEntry(1); // InteroperabilityIndex $this->assertIsA($entry, 'PelEntryAscii'); $this->assertEqual($entry->getValue(), 'R98'); $this->assertEqual($entry->getText(), 'R98'); $entry = $ifd0_0_0->getEntry(2); // InteroperabilityVersion $this->assertIsA($entry, 'PelEntryVersion'); $this->assertEqual($entry->getValue(), 1); $this->assertEqual($entry->getText(), 'Interoperability Version 1.0'); $entry = $ifd0_0_0->getEntry(4097); // RelatedImageWidth $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 640); $this->assertEqual($entry->getText(), '640'); $entry = $ifd0_0_0->getEntry(4098); // RelatedImageLength $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 480); $this->assertEqual($entry->getText(), '480'); /* Sub IFDs of $ifd0_0_0. */ $this->assertEqual(count($ifd0_0_0->getSubIfds()), 0); $this->assertEqual($ifd0_0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_0_1 = $ifd0_0_0->getNextIfd(); $this->assertNull($ifd0_0_1); /* End of IFD $ifd0_0_0. */ $this->assertEqual($ifd0_0->getThumbnailData(), ''); /* Next IFD. */ $ifd0_1 = $ifd0_0->getNextIfd(); $this->assertNull($ifd0_1); /* End of IFD $ifd0_0. */ $this->assertEqual($ifd0->getThumbnailData(), ''); /* Next IFD. */ $ifd1 = $ifd0->getNextIfd(); $this->assertIsA($ifd1, 'PelIfd'); /* End of IFD $ifd0. */ /* Start of IDF $ifd1. */ $this->assertEqual(count($ifd1->getEntries()), 4); $entry = $ifd1->getEntry(259); // Compression $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 6); $this->assertEqual($entry->getText(), 'JPEG compression'); $entry = $ifd1->getEntry(282); // XResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd1->getEntry(283); // YResolution $this->assertIsA($entry, 'PelEntryRational'); $this->assertEqual($entry->getValue(), array(0 => 180, 1 => 1)); $this->assertEqual($entry->getText(), '180/1'); $entry = $ifd1->getEntry(296); // ResolutionUnit $this->assertIsA($entry, 'PelEntryShort'); $this->assertEqual($entry->getValue(), 2); $this->assertEqual($entry->getText(), 'Inch'); /* Sub IFDs of $ifd1. */ $this->assertEqual(count($ifd1->getSubIfds()), 0); $thumb_data = file_get_contents(dirname(__FILE__) . '/canon-ixus-ii-thumb.jpg'); $this->assertEqual($ifd1->getThumbnailData(), $thumb_data); /* Next IFD. */ $ifd2 = $ifd1->getNextIfd(); $this->assertNull($ifd2); /* End of IFD $ifd1. */ $this->assertTrue(count(Pel::getExceptions()) == 0);
public function proceedList($zoom, $zoomTmp) { $pic_list_array = $zoom['config']['pic_list_array']; $pic_list_data = $zoom['config']['pic_list_data']; $picSave = $zoom['config']['pic']; if (!$zoom['config']['imgFileOpt']) { $zoom['config']['imgFileOpt'] = array(); } if (!empty($pic_list_array) && !empty($pic_list_data)) { settype($_GET['zoomID'], 'int'); reset($pic_list_array); if (isset($_GET['zoomFile'])) { if (in_array($_GET['zoomFile'], $pic_list_array)) { $flipedArray = array_flip($pic_list_array); $_GET['zoomID'] = $flipedArray[$_GET['zoomFile']]; } } if (!$_GET['zoomID'] or !array_key_exists($_GET['zoomID'], $pic_list_array)) { $_GET['zoomID'] = key($pic_list_array); $zoom['config']['pZoomID'] = false; } else { $zoom['config']['pZoomID'] = $_GET['zoomID']; } if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $startTime = microtime(true); $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); if (!is_dir($zoom['config']['picDir'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash('/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); if (is_dir($zoom['config']['picDir'])) { $zoom['config']['pic'] = ''; } else { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['installPath'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); if (is_dir($zoom['config']['picDir'])) { $zoom['config']['pic'] = $zoom['config']['installPath']; } } } $this->readTime['findPathFirstImage1'] = $this->endTimeDiff($startTime); } if (!isset($_GET['zoomData']) && !file_exists($zoom['config']['picDir'] . $pic_list_array[$_GET['zoomID']])) { unset($_GET['zoomID']); $pic_list_temp_array = $pic_list_array; $zoomTmp['errorImages'] = array(); $startTime = microtime(true); foreach ($pic_list_array as $k => $v) { if (isset($pic_list_data[$k]['path'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$k]['path'], 'add'), 'add'); } if (file_exists($zoom['config']['picDir'] . $pic_list_array[$k])) { if (!$zoomTmp['picFound']) { $_GET['zoomID'] = $k; $zoomTmp['picFound'] = $k; } } else { $zoomTmp['errorImages'][$k] = $zoom['config']['picDir'] . $pic_list_array[$k]; unset($pic_list_temp_array[$k]); unset($pic_list_data[$k]); } } $this->readTime['findPathFirstImage2'] = $this->endTimeDiff($startTime); if ($zoom['config']['errors'] && !empty($zoomTmp['errorImages'])) { $zoomTmp['fileErrorTitle'] = "Error images missing"; foreach ($zoomTmp['errorImages'] as $k => $v) { $zoomTmp['fileErrorText'] .= "<li>{$v}</li> "; } $zoomTmp['fileErrorText'] = "<ul>" . $zoomTmp['fileErrorText'] . "</ul>"; $this->fileErrorDialog = "<script type=\"text/javascript\">jQuery.fn.axZm.zoomAlert('" . $zoomTmp['fileErrorText'] . "','" . $zoomTmp['fileErrorTitle'] . "',false);</script>"; } $pic_list_array = $pic_list_temp_array; } $zoom['config']['pic_list_array'] = $pic_list_array; $zoom['config']['pic_list_data'] = $pic_list_data; if ($zoom['config']['exifAutoRotation'] && !isset($_GET['str']) && !isset($_GET['qq']) && !isset($_GET['setHW']) && !defined('PHALANGER')) { $pelLib = false; if (file_exists(dirname(__FILE__) . '/classes/pel/PelJpeg.php')) { $pelLib = true; require_once dirname(__FILE__) . '/classes/pel/PelDataWindow.php'; require_once dirname(__FILE__) . '/classes/pel/PelJpeg.php'; require_once dirname(__FILE__) . '/classes/pel/PelTiff.php'; } $startTime = microtime(true); foreach ($pic_list_array as $k => $v) { if (strtolower($this->getl('.', $v)) == 'jpg' || strtolower($this->getl('.', $v)) == 'jpeg') { if (isset($pic_list_data[$k]['path'])) { $tempPicDir = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$k]['path'], 'add'), 'add'); } else { $tempPicDir = $zoom['config']['picDir']; } $aryEXIF = array(); $aryEXIF = exif_read_data($tempPicDir . $v); if (isset($aryEXIF["Orientation"]) && ($aryEXIF["Orientation"] == 6 || $aryEXIF["Orientation"] == 8 || $aryEXIF["Orientation"] == 3)) { $angle = 0; if ($aryEXIF["Orientation"] == 6) { $angle = 270; } elseif ($aryEXIF["Orientation"] == 8) { $angle = 90; } elseif ($aryEXIF["Orientation"] == 3) { $angle = 180; } if ($angle != 0) { if (is_writable($tempPicDir . $v)) { $this->removeAxZm($zoom, $v, array('In' => true, 'Th' => true, 'tC' => true, 'mO' => true, 'Ti' => true, 'gP' => true), false); if ($pelLib) { $sourceExifFile = new PelJpeg($tempPicDir . $v); $sourceExifInfo = $sourceExifFile->getExif(); } if ($zoom['config']['im']) { $arrAngle = array('270' => '90', '90' => '-90', '180' => '180'); $convertString = $this->whichConvert($zoom['config']['imPath']) . " '" . $tempPicDir . $v . "' -rotate '" . $arrAngle[$angle] . "' '" . $tempPicDir . $v . "'"; $convertString = $this->imQuotes($zoom, $convertString); exec($convertString); } else { $rotatedImage = $this->rotateImage($tempPicDir . $v, $angle); imagejpeg($rotatedImage, $tempPicDir . $v, 100); } if ($pelLib) { $outputExifFile = new PelJpeg($tempPicDir . $v); if ($sourceExifInfo != null) { $outputExifFile->setExif($sourceExifInfo); file_put_contents($tempPicDir . $v, $outputExifFile->getBytes()); } $this->exifOrientation($tempPicDir . $v, $tempPicDir . $v); } $pic_list_data[$k]['imgSize'] = $this->axZm->imageSize($tempPicDir . $v, $zoom['config']['im'], false); } else { if ($zoom['config']['errors']) { echo 'alert("' . $tempPicDir . $v . ' is not writable by PHP.");'; } } } } } $zoom['config']['pic_list_data'] = $pic_list_data; } $this->readTime['exifAutoRotation'] = $this->endTimeDiff($startTime); } if ($zoom['config']['cTimeCompare'] && !isset($_GET['setHW']) && !isset($_GET['str']) && !isset($_GET['qq'])) { $this->cTimeCompare($zoom); } if (isset($_GET['zoomID']) && !isset($_GET['qq'])) { if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $zoom['config']['picDir'] = $this->checkSlash($zoom['config']['fpPP'] . $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'), 'add'); } $zoom['config']['orgImgName'] = $pic_list_array[$_GET['zoomID']]; if ($pic_list_data[$_GET['zoomID']]['imgSize']) { $zoom['config']['orgImgSize'] = $pic_list_data[$_GET['zoomID']]['imgSize']; } else { $zoom['config']['orgImgSize'] = $this->axZm->imageSize($zoom['config']['picDir'] . $zoom['config']['orgImgName'], $zoom['config']['im'], false); } $zoom['config']['smallImgName'] = $this->composeFileName($pic_list_array[$_GET['zoomID']], $zoom['config']['picDim'], '_', $this->pngMod($zoom)); $imageSlicer = $zoom['config']['imageSlicer']; if (!is_array($imageSlicer)) { $imageSlicer = array(); } $slicerPostArr = array('zoomID' => $_GET['zoomID'], 'example' => $_GET['example'], 'pic' => $zoom['config']['pic'], 'pic_list_data' => serialize(array($_GET['zoomID'] => $pic_list_data[$_GET['zoomID']])), 'pic_list_array' => serialize(array($_GET['zoomID'] => $pic_list_array[$_GET['zoomID']]))); if ($imageSlicer['enabled'] && !empty($imageSlicer['parameters'])) { foreach ($imageSlicer['parameters'] as $a => $b) { if (isset($_GET[$b])) { $slicerPostArr[$b] = $_GET[$b]; } } } $checkInitialImage = true; if (!$zoom['config']['imgFileOpt']['noMakeFirstImage']) { if ($zoom['config']['stepPicDim'] && is_array($zoom['config']['stepPicDim']) && !empty($zoom['config']['stepPicDim'])) { foreach ($zoom['config']['stepPicDim'] as $k => $v) { if ((int) $v['w'] && (int) $v['h'] && !file_exists($zoom['config']['thumbDir'] . $this->md5path($zoom['config']['orgImgName'], $zoom['config']['subfolderStructure']) . '/' . $this->composeFileName($zoom['config']['orgImgName'], (int) $v['w'] . 'x' . (int) $v['h'], '_', $this->pngMod($zoom)))) { $checkInitialImage = false; break; } } } else { $checkInitialImage = file_exists($zoom['config']['thumbDir'] . $this->md5path($zoom['config']['orgImgName'], $zoom['config']['subfolderStructure']) . $zoom['config']['smallImgName']); } } if (!$checkInitialImage) { if ($imageSlicer['enabled']) { $slicerPostArr['task'] = 'makeFirstImage'; $this->returnMakeFirstImage = $this->httpRequestQuery($imageSlicer['method'], $imageSlicer['host'], $imageSlicer['port'], $imageSlicer['uri'], $imageSlicer['timeout'], $imageSlicer['method'] == 'GET' ? $slicerPostArr : array(), $imageSlicer['method'] == 'POST' ? $slicerPostArr : array(), $imageSlicer['headers']); } else { $startTime = microtime(true); $this->returnMakeFirstImage = $this->axZm->makeFirstImage($zoom, false); $this->readTime['makeFirstImage1'] = $this->endTimeDiff($startTime); } } elseif ($zoom['config']['mapOwnImage'] && !$zoom['config']['imgFileOpt']['noMakeMapImage']) { if (!isset($zoom['config']['mapDir'])) { $zoom['config']['mapDir'] = $this->checkSlash($zoom['config']['fpPP'] . $zoom['config']['mapPath'], 'add'); } if (!file_exists($zoom['config']['mapDir'] . $this->composeFileName($zoom['config']['orgImgName'], $zoom['config']['mapOwnImage'], '_', $this->pngMod($zoom)))) { if ($imageSlicer['enabled']) { $slicerPostArr['task'] = 'makeMapImage'; $this->returnMakeFirstImage = $this->httpRequestQuery($imageSlicer['method'], $imageSlicer['host'], $imageSlicer['port'], $imageSlicer['uri'], $imageSlicer['timeout'], $imageSlicer['method'] == 'GET' ? $slicerPostArr : array(), $imageSlicer['method'] == 'POST' ? $slicerPostArr : array(), $imageSlicer['headers']); } else { $startTime = microtime(true); $this->returnMakeFirstImage = $this->axZm->makeFirstImage($zoom, true); $this->readTime['makeFirstImage2'] = $this->endTimeDiff($startTime); } } } $startTime = microtime(true); if ($zoom['config']['imgFileOpt']['noMakeFirstImage']) { $zoom['config']['smallImgSize'] = $this->virtualResize($pic_list_data[$_GET['zoomID']]['imgSize'], array($zoom['config']['picX'], $zoom['config']['picY'])); } else { $zoom['config']['smallImgSize'] = $this->axZm->imageSize($zoom['config']['thumbDir'] . $this->md5path($zoom['config']['orgImgName'], $zoom['config']['subfolderStructure']) . $zoom['config']['smallImgName'], $zoom['config']['im'], false); } $this->readTime['smallImgSizeDim'] = $this->endTimeDiff($startTime); if ($zoom['config']['imgFileOpt']['getFileSize']) { $startTime = microtime(true); $zoom['config']['smallFileSize'] = filesize($zoom['config']['thumbDir'] . $this->md5path($zoom['config']['orgImgName'], $zoom['config']['subfolderStructure']) . $zoom['config']['smallImgName']); $this->readTime['smallImgFileSize'] = $this->endTimeDiff($startTime); } if (isset($_GET['setHW'])) { echo "<script type=\"text/javascript\">"; echo "\r\n\t\t\t\t\tjQuery.axZm.iw=" . $this->ptj($zoom['config']['smallImgSize'][0]) . ";\r\n\t\t\t\t\tjQuery.axZm.ih=" . $this->ptj($zoom['config']['smallImgSize'][1]) . ";\r\n\t\t\t\t\t"; echo "</script>\r\n\t\t\t\t\t"; if (!is_bool($this->returnMakeFirstImage)) { echo $this->returnMakeFirstImage; } } if (!isset($_GET['str'])) { if (!isset($_GET['setHW'])) { $firstThumbSize = null; $startTime = microtime(true); foreach ($pic_list_array as $k => $v) { $zoomTmp['smallImgNameTemp'] = $this->composeFileName($v, $zoom['config']['picDim'], '_', $this->pngMod($zoom)); if ($zoom['config']['imgFileOpt']['noMakeFirstImage']) { $pic_list_data[$k]['thumbSize'] = $this->virtualResize($pic_list_data[$k]['imgSize'], array($zoom['config']['picX'], $zoom['config']['picY'])); } else { if (file_exists($zoom['config']['thumbDir'] . $this->md5path($v, $zoom['config']['subfolderStructure']) . $zoomTmp['smallImgNameTemp'])) { if ($firstThumbSize && ($zoom['config']['imgFileOpt']['sameAspectRatio'] || $zoom['config']['imgFileOpt']['sameSize'] || $zoom['config']['spinMod'])) { $pic_list_data[$k]['thumbSize'] = $firstThumbSize; } else { $pic_list_data[$k]['thumbSize'] = $this->axZm->imageSize($zoom['config']['thumbDir'] . $this->md5path($v, $zoom['config']['subfolderStructure']) . $zoomTmp['smallImgNameTemp'], $zoom['config']['im'], false); } if (!$firstThumbSize) { $firstThumbSize = $pic_list_data[$k]['thumbSize']; } } else { $pic_list_data[$k]['thumbSize'] = false; } } } $this->readTime['smallImgSizeDimAll'] = $this->endTimeDiff($startTime); $zoom['config']['pic_list_data'] = $pic_list_data; if ((!isset($zoom['config']['galleryNoThumbs']) || $zoom['config']['galleryNoThumbs'] === false) && !$zoom['config']['imgFileOpt']['noMakeAllThumbs']) { if ($imageSlicer['enabled']) { $slicerPostThumbsArr = array('task' => 'makeAllThumbs', 'zoomID' => $_GET['zoomID'], 'example' => $_GET['example'], 'pic' => $zoom['config']['pic'], 'pic_list_data' => serialize($pic_list_data), 'pic_list_array' => serialize($pic_list_array)); if (!empty($imageSlicer['parameters'])) { foreach ($imageSlicer['parameters'] as $a => $b) { if (isset($_GET[$b])) { $slicerPostThumbsArr[$b] = $_GET[$b]; } } } $this->returnMakeAllThumbs = $this->httpRequestQuery($imageSlicer['method'], $imageSlicer['host'], $imageSlicer['port'], $imageSlicer['uri'], $imageSlicer['timeout'], $imageSlicer['method'] == 'GET' ? $slicerPostThumbsArr : array(), $imageSlicer['method'] == 'POST' ? $slicerPostThumbsArr : array(), $imageSlicer['headers']); } else { $startTime = microtime(true); $this->returnMakeAllThumbs = $this->axZm->makeAllThumbs($zoom); $this->readTime['makeAllThumbs'] = $this->endTimeDiff($startTime); } } else { $this->returnMakeAllThumbs = false; } } if ($zoom['config']['gPyramid'] && $zoom['config']['gPyramidDir']) { $startTime = microtime(true); if (!$zoom['config']['imgFileOpt']['noMakeGpyramid']) { $zoomTmp['gPyramidPicDir'] = $zoom['config']['gPyramidDir'] . $this->md5path($zoom['config']['orgImgName'], $zoom['config']['subfolderStructure']) . $this->getf('.', $zoom['config']['orgImgName']); $zoomTmp['gPyramidPicDirExists'] = is_dir($zoomTmp['gPyramidPicDir']); if (!$zoomTmp['gPyramidPicDirExists']) { if ($imageSlicer['enabled']) { $slicerPostArr['task'] = 'gPyramid'; $this->returnMakeZoomTiles = $this->httpRequestQuery($imageSlicer['method'], $imageSlicer['host'], $imageSlicer['port'], $imageSlicer['uri'], $imageSlicer['timeout'], $imageSlicer['method'] == 'GET' ? $slicerPostArr : array(), $imageSlicer['method'] == 'POST' ? $slicerPostArr : array(), $imageSlicer['headers']); } else { $this->returnMakeZoomTiles = $this->axZm->gPyramid($zoom); } if (isset($_GET['setHW']) && !is_bool($this->returnMakeZoomTiles)) { echo $this->returnMakeZoomTiles; } } } $this->readTime['gPyramid'] = $this->endTimeDiff($startTime); } if ($zoom['config']['pyrTiles'] && $zoom['config']['pyrTilesDir']) { $startTime = microtime(true); if (!$zoom['config']['imgFileOpt']['noMakeZoomTiles'] && ($zoom['config']['orgImgSize'][0] >= $zoom['config']['tileSize'] || $zoom['config']['orgImgSize'][1] >= $zoom['config']['tileSize'])) { $this->returnMakeZoomTiles = $this->axZm->zC($zoom, false); if (!$zoom['config']['imgFileOpt']['noMakeZoomTiles'] && !$this->tileExists($zoom, $zoom['config']['orgImgName'])) { if ($imageSlicer['enabled']) { $slicerPostArr['task'] = 'makeZoomTiles'; $this->returnMakeZoomTiles = $this->httpRequestQuery($imageSlicer['method'], $imageSlicer['host'], $imageSlicer['port'], $imageSlicer['uri'], $imageSlicer['timeout'], $imageSlicer['method'] == 'GET' ? $slicerPostArr : array(), $imageSlicer['method'] == 'POST' ? $slicerPostArr : array(), $imageSlicer['headers']); } else { $this->returnMakeZoomTiles = $this->axZm->makeZoomTiles($zoom); } } if (isset($_GET['setHW']) && !is_bool($this->returnMakeZoomTiles) && $this->returnMakeZoomTiles) { echo $this->returnMakeZoomTiles; } } $this->readTime['makeZoomTiles'] = $this->endTimeDiff($startTime); } if (!isset($_GET['setHW'])) { $startTime = microtime(true); foreach ($pic_list_data as $k => $v) { $zoom['config']['galArray'][$k]['img'] = $v['fileName']; $zoom['config']['galArray'][$k]['ow'] = $v['imgSize'][0]; $zoom['config']['galArray'][$k]['oh'] = $v['imgSize'][1]; $zoom['config']['galArray'][$k]['iw'] = $v['thumbSize'][0]; $zoom['config']['galArray'][$k]['ih'] = $v['thumbSize'][1]; $zoom['config']['galArray'][$k]['tD'] = $v['thumbDescr']; $zoom['config']['galArray'][$k]['fD'] = $v['fullDescr']; $zoom['config']['galArray'][$k]['mf'] = false; $zoom['config']['galArray'][$k]['mk'] = false; if ($zoom['config']['useMap'] && !$zoom['config']['imgFileOpt']['noMakeMapImage'] && $zoom['config']['mapOwnImage'] && $zoom['config']['mapDir']) { $ownImageSize = explode('x', $zoom['config']['mapOwnImage']); $ownImageName = $this->composeFileName($v['fileName'], $ownImageSize[0] . 'x' . $ownImageSize[1], '_', $this->pngMod($zoom)); if (!file_exists($zoom['config']['mapDir'] . $this->md5path($v['fileName'], $zoom['config']['subfolderStructure']) . $ownImageName)) { $zoom['config']['galArray'][$k]['mf'] = true; } } if ($zoom['config']['stepPicDim'] && !$zoom['config']['imgFileOpt']['noMakeFirstImage'] && is_array($zoom['config']['stepPicDim']) && !empty($zoom['config']['stepPicDim'])) { foreach ($zoom['config']['stepPicDim'] as $a => $b) { if ((int) $b['w'] && (int) $b['h'] && !file_exists($zoom['config']['thumbDir'] . $this->md5path($v['fileName'], $zoom['config']['subfolderStructure']) . $this->composeFileName($v['fileName'], (int) $b['w'] . 'x' . (int) $b['h'], '_', $this->pngMod($zoom)))) { $zoom['config']['galArray'][$k]['mf'] = true; break; } } } if (isset($v['path'])) { $zoom['config']['galArray'][$k]['ph'] = $this->checkSlash($v['picPath'], 'add'); } if ($zoom['config']['gPyramid'] && !$zoom['config']['imgFileOpt']['noMakeGpyramid']) { if (is_dir($zoom['config']['gPyramidDir'] . $this->md5path($v['fileName'], $zoom['config']['subfolderStructure']) . $this->getf('.', $v['fileName']))) { $zoom['config']['galArray'][$k]['mk'] = false; } else { $zoom['config']['galArray'][$k]['mk'] = 'gP'; } } elseif ($zoom['config']['pyrTiles'] && !$zoom['config']['imgFileOpt']['noMakeZoomTiles']) { if ($v['imgSize'][0] < $zoom['config']['tileSize'] && $v['imgSize'][1] < $zoom['config']['tileSize'] || $this->tileExists($zoom, $v['fileName'])) { $zoom['config']['galArray'][$k]['mk'] = false; if ($zoom['config']['pyrAutoDetect']) { $zoom['config']['galArray'][$k]['ts'] = $this->getTileSize($zoom, $v['fileName']); } } else { $zoom['config']['galArray'][$k]['mk'] = 'tL'; } } } $this->readTime['galleryData'] = $this->endTimeDiff($startTime); } } if (isset($pic_list_data[$_GET['zoomID']]['path'])) { $zoom['config']['pic'] = $this->checkSlash($zoom['config']['pic'] . '/' . $pic_list_data[$_GET['zoomID']]['path'], 'add'); } } } else { unset($_GET['zoomID']); } $this->readTime['pyrAutoDetect'] = $zoom['config']['pyrAutoDetect']; $this->readTime['imgFileOpt'] = $zoom['config']['imgFileOpt']; return array($zoom, $zoomTmp); }