Beispiel #1
0
 function __construct($min, $max)
 {
     Pel::setStrictParsing(true);
     $this->min = $min;
     $this->max = $max;
     parent::__construct('PEL Exif Number Tests');
 }
Beispiel #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);
 }
Beispiel #3
0
 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');
 }
Beispiel #4
0
 /**
  * Get the value of an entry as text.
  *
  * The value will be returned in a format suitable for presentation,
  * e.g., rationals will be returned as 'x/y', ASCII strings will be
  * returned as themselves etc.
  *
  * @param boolean some values can be returned in a long or more
  * brief form, and this parameter controls that.
  *
  * @return string the value as text.
  */
 function getText($brief = false)
 {
     if (isset($this->value[0])) {
         $v = $this->value[0];
     }
     switch ($this->tag) {
         case PelTag::SHUTTER_SPEED_VALUE:
             //CC (e->components, 1, v);
             //if (!v_srat.denominator) return (NULL);
             return Pel::fmt('%.0f/%.0f sec. (APEX: %d)', $v[0], $v[1], pow(sqrt(2), $v[0] / $v[1]));
         case PelTag::BRIGHTNESS_VALUE:
             //CC (e->components, 1, v);
             //
             // TODO: figure out the APEX thing, or remove this so that it is
             // handled by the default clause at the bottom.
             return sprintf('%d/%d', $v[0], $v[1]);
             //FIXME: How do I calculate the APEX value?
         //FIXME: How do I calculate the APEX value?
         case PelTag::EXPOSURE_BIAS_VALUE:
             //CC (e->components, 1, v);
             //if (!v_srat.denominator) return (NULL);
             return sprintf('%s%.01f', $v[0] * $v[1] > 0 ? '+' : '', $v[0] / $v[1]);
         default:
             return parent::getText($brief);
     }
 }
 /**
  * Validate a number.
  *
  * This method will check that the number given is within the range
  * given my {@link getMin()} and {@link getMax()}, inclusive.  If
  * not, then a {@link PelOverflowException} is thrown.
  *
  * @param int|array the number in question.
  *
  * @return void nothing, but will throw a {@link
  * PelOverflowException} if the number is found to be outside the
  * legal range and {@link Pel::$strict} is true.
  */
 function validateNumber($n)
 {
     if ($this->dimension == 1) {
         if ($n < $this->min || $n > $this->max) {
             Pel::maybeThrow(new PelOverflowException($n, $this->min, $this->max));
         }
     } else {
         for ($i = 0; $i < $this->dimension; $i++) {
             if ($n[$i] < $this->min || $n[$i] > $this->max) {
                 Pel::maybeThrow(new PelOverflowException($n[$i], $this->min, $this->max));
             }
         }
     }
 }
Beispiel #6
0
 /**
  * Return a string representation of this object.
  *
  * @return string a string describing this object. This is mostly
  *         useful for debugging.
  */
 public function __toString()
 {
     return Pel::tra("Dumping Exif data...\n") . $this->tiff->__toString();
 }
Beispiel #7
0
 /**
  * Make a string representation of this JPEG object.
  *
  * This is mainly usefull for debugging.  It will show the structure
  * of the image, and its sections.
  *
  * @return string debugging information about this JPEG object.
  */
 function __toString()
 {
     $str = Pel::tra("Dumping JPEG data...\n");
     for ($i = 0; $i < count($this->sections); $i++) {
         $m = $this->sections[$i][0];
         $c = $this->sections[$i][1];
         $str .= Pel::fmt("Section %d (marker 0x%02X - %s):\n", $i, $m, PelJpegMarker::getName($m));
         $str .= Pel::fmt("  Description: %s\n", PelJpegMarker::getDescription($m));
         if ($m == PelJpegMarker::SOI || $m == PelJpegMarker::EOI) {
             continue;
         }
         if ($c instanceof PelExif) {
             $str .= Pel::tra("  Content    : Exif data\n");
             $str .= $c->__toString() . "\n";
         } elseif ($c instanceof PelJpegComment) {
             $str .= Pel::fmt("  Content    : %s\n", $c->getValue());
         } else {
             $str .= Pel::tra("  Content    : Unknown\n");
         }
     }
     return $str;
 }
    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);
Beispiel #9
0
 /**
  * Turn this entry into a string.
  *
  * @return string a string representation of this entry.  This is
  * mostly for debugging.
  */
 function __toString()
 {
     $str = Pel::fmt("  Tag: 0x%04X (%s)\n", $this->tag, PelTag::getName($this->ifd_type, $this->tag));
     $str .= Pel::fmt("    Format    : %d (%s)\n", $this->format, PelFormat::getName($this->format));
     $str .= Pel::fmt("    Components: %d\n", $this->components);
     if ($this->getTag() != PelTag::MAKER_NOTE && $this->getTag() != PelTag::PRINT_IM) {
         $str .= Pel::fmt("    Value     : %s\n", print_r($this->getValue(), true));
     }
     $str .= Pel::fmt("    Text      : %s\n", $this->getText());
     return $str;
 }
Beispiel #10
0
    print "Mandatory arguments:\n";
    print "  filename  a JPEG or TIFF image.\n";
    exit(1);
}
if (!is_readable($file)) {
    printf("Unable to read %s!\n", $file);
    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');
$data = new PelDataWindow(file_get_contents($file));
if (PelJpeg::isValid($data)) {
    $img = new PelJpeg();
} elseif (PelTiff::isValid($data)) {
    $img = new PelTiff();
} else {
    print "Unrecognized image format! The first 16 bytes follow:\n";
    PelConvert::bytesToDump($data->getBytes(0, 16));
    exit(1);
}
/* Try loading the data. */
$img->load($data);
print $img;
/* Deal with any exceptions: */
if (count(Pel::getExceptions()) > 0) {
    print "\nThe following errors were encountered while loading the image:\n";
    foreach (Pel::getExceptions() as $e) {
        print "\n" . $e->__toString();
    }
}
Beispiel #11
0
 /**
  * Enable/disable debugging output.
  *
  * @param boolean $flag use true to enable debug output, false to
  * diable.
  */
 function setDebug($flag)
 {
     self::$debug = $flag;
 }
    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. */
Beispiel #13
0
 /**
  * Return a string representation of the data window.
  *
  * @return string a description of the window with information about
  *         the number of bytes accessible, the total number of bytes, and
  *         the window start and stop.
  */
 public function __toString()
 {
     return Pel::fmt('DataWindow: %d bytes in [%d, %d] of %d bytes', $this->size, $this->start, $this->start + $this->size, strlen($this->data));
 }
Beispiel #14
0
    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. */
Beispiel #15
0
setlocale(LC_ALL, '');
/* Load the required PEL files for handling JPEG images. */
require_once '../autoload.php';
use lsolesen\pel\PelJpeg;
/*
 * Store the name of the script in $prog and remove this first part of
 * the command line.
 */
$prog = array_shift($argv);
$error = false;
/*
 * The next argument could be -d to signal debug mode where lots of
 * extra information is printed out when the image is parsed.
 */
if (isset($argv[0]) && $argv[0] == '-d') {
    Pel::setDebug(true);
    array_shift($argv);
}
/* The mandatory input filename. */
if (isset($argv[0])) {
    $input = array_shift($argv);
} else {
    $error = true;
}
/* The mandatory output filename. */
if (isset($argv[0])) {
    $output = array_shift($argv);
} else {
    $error = true;
}
/* The mandatory scale factor. */
Beispiel #16
0
 /**
  * Returns a title for an Exif tag.
  *
  * @param
  *            int the IFD type of the tag, one of {@link PelIfd::IFD0},
  *            {@link PelIfd::IFD1}, {@link PelIfd::EXIF}, {@link PelIfd::GPS},
  *            or {@link PelIfd::INTEROPERABILITY}.
  *
  * @param
  *            PelTag the tag.
  *
  * @return string the title of the tag, e.g., 'Image Width' for the
  *         {@link IMAGE_WIDTH} tag. If the tag isn't known, the string
  *         'Unknown Tag: 0xTT' will be returned where 'TT' is the
  *         hexadecimal representation of the tag.
  */
 public function getTitle($type, $tag)
 {
     switch ($type) {
         case PelIfd::IFD0:
         case PelIfd::IFD1:
         case PelIfd::EXIF:
         case PelIfd::INTEROPERABILITY:
             switch ($tag) {
                 case self::INTEROPERABILITY_INDEX:
                     return Pel::tra('Interoperability Index');
                 case self::INTEROPERABILITY_VERSION:
                     return Pel::tra('Interoperability Version');
                 case self::IMAGE_WIDTH:
                     return Pel::tra('Image Width');
                 case self::IMAGE_LENGTH:
                     return Pel::tra('Image Length');
                 case self::BITS_PER_SAMPLE:
                     return Pel::tra('Bits per Sample');
                 case self::COMPRESSION:
                     return Pel::tra('Compression');
                 case self::PHOTOMETRIC_INTERPRETATION:
                     return Pel::tra('Photometric Interpretation');
                 case self::FILL_ORDER:
                     return Pel::tra('Fill Order');
                 case self::DOCUMENT_NAME:
                     return Pel::tra('Document Name');
                 case self::IMAGE_DESCRIPTION:
                     return Pel::tra('Image Description');
                 case self::MAKE:
                     return Pel::tra('Manufacturer');
                 case self::MODEL:
                     return Pel::tra('Model');
                 case self::STRIP_OFFSETS:
                     return Pel::tra('Strip Offsets');
                 case self::ORIENTATION:
                     return Pel::tra('Orientation');
                 case self::SAMPLES_PER_PIXEL:
                     return Pel::tra('Samples per Pixel');
                 case self::ROWS_PER_STRIP:
                     return Pel::tra('Rows per Strip');
                 case self::STRIP_BYTE_COUNTS:
                     return Pel::tra('Strip Byte Count');
                 case self::X_RESOLUTION:
                     return Pel::tra('x-Resolution');
                 case self::Y_RESOLUTION:
                     return Pel::tra('y-Resolution');
                 case self::PLANAR_CONFIGURATION:
                     return Pel::tra('Planar Configuration');
                 case self::RESOLUTION_UNIT:
                     return Pel::tra('Resolution Unit');
                 case self::TRANSFER_FUNCTION:
                     return Pel::tra('Transfer Function');
                 case self::SOFTWARE:
                     return Pel::tra('Software');
                 case self::DATE_TIME:
                     return Pel::tra('Date and Time');
                 case self::ARTIST:
                     return Pel::tra('Artist');
                 case self::WHITE_POINT:
                     return Pel::tra('White Point');
                 case self::PRIMARY_CHROMATICITIES:
                     return Pel::tra('Primary Chromaticities');
                 case self::TRANSFER_RANGE:
                     return Pel::tra('Transfer Range');
                 case self::JPEG_PROC:
                     return Pel::tra('JPEG Process');
                 case self::JPEG_INTERCHANGE_FORMAT:
                     return Pel::tra('JPEG Interchange Format');
                 case self::JPEG_INTERCHANGE_FORMAT_LENGTH:
                     return Pel::tra('JPEG Interchange Format Length');
                 case self::YCBCR_COEFFICIENTS:
                     return Pel::tra('YCbCr Coefficients');
                 case self::YCBCR_SUB_SAMPLING:
                     return Pel::tra('YCbCr Sub-Sampling');
                 case self::YCBCR_POSITIONING:
                     return Pel::tra('YCbCr Positioning');
                 case self::REFERENCE_BLACK_WHITE:
                     return Pel::tra('Reference Black/White');
                 case self::RELATED_IMAGE_FILE_FORMAT:
                     return Pel::tra('Related Image File Format');
                 case self::RELATED_IMAGE_WIDTH:
                     return Pel::tra('Related Image Width');
                 case self::RELATED_IMAGE_LENGTH:
                     return Pel::tra('Related Image Length');
                 case self::CFA_REPEAT_PATTERN_DIM:
                     return Pel::tra('CFA Repeat Pattern Dim');
                 case self::CFA_PATTERN:
                     return Pel::tra('CFA Pattern');
                 case self::BATTERY_LEVEL:
                     return Pel::tra('Battery Level');
                 case self::COPYRIGHT:
                     return Pel::tra('Copyright');
                 case self::EXPOSURE_TIME:
                     return Pel::tra('Exposure Time');
                 case self::FNUMBER:
                     return Pel::tra('FNumber');
                 case self::IPTC_NAA:
                     return Pel::tra('IPTC/NAA');
                 case self::EXIF_IFD_POINTER:
                     return Pel::tra('Exif IFD Pointer');
                 case self::INTER_COLOR_PROFILE:
                     return Pel::tra('Inter Color Profile');
                 case self::EXPOSURE_PROGRAM:
                     return Pel::tra('Exposure Program');
                 case self::SPECTRAL_SENSITIVITY:
                     return Pel::tra('Spectral Sensitivity');
                 case self::GPS_INFO_IFD_POINTER:
                     return Pel::tra('GPS Info IFD Pointer');
                 case self::ISO_SPEED_RATINGS:
                     return Pel::tra('ISO Speed Ratings');
                 case self::OECF:
                     return Pel::tra('OECF');
                 case self::EXIF_VERSION:
                     return Pel::tra('Exif Version');
                 case self::DATE_TIME_ORIGINAL:
                     return Pel::tra('Date and Time (original)');
                 case self::DATE_TIME_DIGITIZED:
                     return Pel::tra('Date and Time (digitized)');
                 case self::COMPONENTS_CONFIGURATION:
                     return Pel::tra('Components Configuration');
                 case self::COMPRESSED_BITS_PER_PIXEL:
                     return Pel::tra('Compressed Bits per Pixel');
                 case self::SHUTTER_SPEED_VALUE:
                     return Pel::tra('Shutter speed');
                 case self::APERTURE_VALUE:
                     return Pel::tra('Aperture');
                 case self::BRIGHTNESS_VALUE:
                     return Pel::tra('Brightness');
                 case self::EXPOSURE_BIAS_VALUE:
                     return Pel::tra('Exposure Bias');
                 case self::MAX_APERTURE_VALUE:
                     return Pel::tra('Max Aperture Value');
                 case self::SUBJECT_DISTANCE:
                     return Pel::tra('Subject Distance');
                 case self::METERING_MODE:
                     return Pel::tra('Metering Mode');
                 case self::LIGHT_SOURCE:
                     return Pel::tra('Light Source');
                 case self::FLASH:
                     return Pel::tra('Flash');
                 case self::FOCAL_LENGTH:
                     return Pel::tra('Focal Length');
                 case self::MAKER_NOTE:
                     return Pel::tra('Maker Note');
                 case self::USER_COMMENT:
                     return Pel::tra('User Comment');
                 case self::SUB_SEC_TIME:
                     return Pel::tra('SubSec Time');
                 case self::SUB_SEC_TIME_ORIGINAL:
                     return Pel::tra('SubSec Time Original');
                 case self::SUB_SEC_TIME_DIGITIZED:
                     return Pel::tra('SubSec Time Digitized');
                 case self::XP_TITLE:
                     return 'Windows XP Title';
                 case self::XP_COMMENT:
                     return 'Windows XP Comment';
                 case self::XP_AUTHOR:
                     return 'Windows XP Author';
                 case self::XP_KEYWORDS:
                     return 'Windows XP Keywords';
                 case self::XP_SUBJECT:
                     return 'Windows XP Subject';
                 case self::FLASH_PIX_VERSION:
                     return Pel::tra('FlashPix Version');
                 case self::COLOR_SPACE:
                     return Pel::tra('Color Space');
                 case self::PIXEL_X_DIMENSION:
                     return Pel::tra('Pixel x-Dimension');
                 case self::PIXEL_Y_DIMENSION:
                     return Pel::tra('Pixel y-Dimension');
                 case self::RELATED_SOUND_FILE:
                     return Pel::tra('Related Sound File');
                 case self::INTEROPERABILITY_IFD_POINTER:
                     return Pel::tra('Interoperability IFD Pointer');
                 case self::FLASH_ENERGY:
                     return Pel::tra('Flash Energy');
                 case self::SPATIAL_FREQUENCY_RESPONSE:
                     return Pel::tra('Spatial Frequency Response');
                 case self::FOCAL_PLANE_X_RESOLUTION:
                     return Pel::tra('Focal Plane x-Resolution');
                 case self::FOCAL_PLANE_Y_RESOLUTION:
                     return Pel::tra('Focal Plane y-Resolution');
                 case self::FOCAL_PLANE_RESOLUTION_UNIT:
                     return Pel::tra('Focal Plane Resolution Unit');
                 case self::SUBJECT_LOCATION:
                     return Pel::tra('Subject Location');
                 case self::EXPOSURE_INDEX:
                     return Pel::tra('Exposure index');
                 case self::SENSING_METHOD:
                     return Pel::tra('Sensing Method');
                 case self::FILE_SOURCE:
                     return Pel::tra('File Source');
                 case self::SCENE_TYPE:
                     return Pel::tra('Scene Type');
                 case self::SUBJECT_AREA:
                     return Pel::tra('Subject Area');
                 case self::CUSTOM_RENDERED:
                     return Pel::tra('Custom Rendered');
                 case self::EXPOSURE_MODE:
                     return Pel::tra('Exposure Mode');
                 case self::WHITE_BALANCE:
                     return Pel::tra('White Balance');
                 case self::DIGITAL_ZOOM_RATIO:
                     return Pel::tra('Digital Zoom Ratio');
                 case self::FOCAL_LENGTH_IN_35MM_FILM:
                     return Pel::tra('Focal Length In 35mm Film');
                 case self::SCENE_CAPTURE_TYPE:
                     return Pel::tra('Scene Capture Type');
                 case self::GAIN_CONTROL:
                     return Pel::tra('Gain Control');
                 case self::CONTRAST:
                     return Pel::tra('Contrast');
                 case self::SATURATION:
                     return Pel::tra('Saturation');
                 case self::SHARPNESS:
                     return Pel::tra('Sharpness');
                 case self::DEVICE_SETTING_DESCRIPTION:
                     return Pel::tra('Device Setting Description');
                 case self::SUBJECT_DISTANCE_RANGE:
                     return Pel::tra('Subject Distance Range');
                 case self::IMAGE_UNIQUE_ID:
                     return Pel::tra('Image Unique ID');
                 case self::GAMMA:
                     return Pel::tra('Gamma');
                 case self::PRINT_IM:
                     return Pel::tra('Print IM');
             }
             return Pel::fmt('Unknown Tag: 0x%04X', $tag);
         case PelIfd::GPS:
             switch ($tag) {
                 case self::GPS_VERSION_ID:
                     return 'GPSVersionID';
                 case self::GPS_LATITUDE_REF:
                     return 'GPSLatitudeRef';
                 case self::GPS_LATITUDE:
                     return 'GPSLatitude';
                 case self::GPS_LONGITUDE_REF:
                     return 'GPSLongitudeRef';
                 case self::GPS_LONGITUDE:
                     return 'GPSLongitude';
                 case self::GPS_ALTITUDE_REF:
                     return 'GPSAltitudeRef';
                 case self::GPS_ALTITUDE:
                     return 'GPSAltitude';
                 case self::GPS_TIME_STAMP:
                     return 'GPSTimeStamp';
                 case self::GPS_SATELLITES:
                     return 'GPSSatellites';
                 case self::GPS_STATUS:
                     return 'GPSStatus';
                 case self::GPS_MEASURE_MODE:
                     return 'GPSMeasureMode';
                 case self::GPS_DOP:
                     return 'GPSDOP';
                 case self::GPS_SPEED_REF:
                     return 'GPSSpeedRef';
                 case self::GPS_SPEED:
                     return 'GPSSpeed';
                 case self::GPS_TRACK_REF:
                     return 'GPSTrackRef';
                 case self::GPS_TRACK:
                     return 'GPSTrack';
                 case self::GPS_IMG_DIRECTION_REF:
                     return 'GPSImgDirectionRef';
                 case self::GPS_IMG_DIRECTION:
                     return 'GPSImgDirection';
                 case self::GPS_MAP_DATUM:
                     return 'GPSMapDatum';
                 case self::GPS_DEST_LATITUDE_REF:
                     return 'GPSDestLatitudeRef';
                 case self::GPS_DEST_LATITUDE:
                     return 'GPSDestLatitude';
                 case self::GPS_DEST_LONGITUDE_REF:
                     return 'GPSDestLongitudeRef';
                 case self::GPS_DEST_LONGITUDE:
                     return 'GPSDestLongitude';
                 case self::GPS_DEST_BEARING_REF:
                     return 'GPSDestBearingRef';
                 case self::GPS_DEST_BEARING:
                     return 'GPSDestBearing';
                 case self::GPS_DEST_DISTANCE_REF:
                     return 'GPSDestDistanceRef';
                 case self::GPS_DEST_DISTANCE:
                     return 'GPSDestDistance';
                 case self::GPS_PROCESSING_METHOD:
                     return 'GPSProcessingMethod';
                 case self::GPS_AREA_INFORMATION:
                     return 'GPSAreaInformation';
                 case self::GPS_DATE_STAMP:
                     return 'GPSDateStamp';
                 case self::GPS_DIFFERENTIAL:
                     return 'GPSDifferential';
             }
             return Pel::fmt('Unknown Tag: 0x%04X', $tag);
         default:
             return Pel::fmt('Unknown Tag: 0x%04X', $tag);
     }
 }
Beispiel #17
0
 /**
  * Enable/disable debugging output.
  *
  * @param boolean $flag
  *            use true to enable debug output, false to
  *            diable.
  */
 public static function setDebug($flag)
 {
     self::$debug = $flag;
 }
    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);
setlocale(LC_ALL, '');
/* Load the required files.  One would normally just require the
 * PelJpeg.php file for dealing with JPEG images, but because this
 * example can handle both JPEG and TIFF it loads the PelDataWindow
 * class too. */
require_once dirname(__FILE__) . '/../PelDataWindow.php';
require_once dirname(__FILE__) . '/../PelJpeg.php';
require_once dirname(__FILE__) . '/../PelTiff.php';
/* Store the name of the script in $prog and remove this first part of
 * the command line. */
$prog = array_shift($argv);
$error = false;
/* The next argument could be -d to signal debug mode where lots of
 * extra information is printed out when the image is parsed. */
if (isset($argv[0]) && $argv[0] == '-d') {
    Pel::$debug = true;
    array_shift($argv);
}
/* The mandatory input filename. */
if (isset($argv[0])) {
    $input = array_shift($argv);
} else {
    $error = true;
}
/* The mandatory output filename. */
if (isset($argv[0])) {
    $output = array_shift($argv);
} else {
    $error = true;
}
/* Usage information is printed if an error was found in the command
 /**
  * Returns a description of a JPEG marker.
  *
  * @param PelJpegMarker the marker.
  *
  * @return string the description of the marker.
  */
 static function getDescription($m)
 {
     switch ($m) {
         case self::SOF0:
             return Pel::tra('Encoding (baseline)');
         case self::SOF1:
             return Pel::tra('Encoding (extended sequential)');
         case self::SOF2:
             return Pel::tra('Encoding (progressive)');
         case self::SOF3:
             return Pel::tra('Encoding (lossless)');
         case self::SOF5:
             return Pel::tra('Encoding (differential sequential)');
         case self::SOF6:
             return Pel::tra('Encoding (differential progressive)');
         case self::SOF7:
             return Pel::tra('Encoding (differential lossless)');
         case self::SOF9:
             return Pel::tra('Encoding (extended sequential, arithmetic)');
         case self::SOF10:
             return Pel::tra('Encoding (progressive, arithmetic)');
         case self::SOF11:
             return Pel::tra('Encoding (lossless, arithmetic)');
         case self::SOF13:
             return Pel::tra('Encoding (differential sequential, arithmetic)');
         case self::SOF14:
             return Pel::tra('Encoding (differential progressive, arithmetic)');
         case self::SOF15:
             return Pel::tra('Encoding (differential lossless, arithmetic)');
         case self::SOI:
             return Pel::tra('Start of image');
         case self::EOI:
             return Pel::tra('End of image');
         case self::SOS:
             return Pel::tra('Start of scan');
         case self::COM:
             return Pel::tra('Comment');
         case self::DHT:
             return Pel::tra('Define Huffman table');
         case self::JPG:
             return Pel::tra('Extension');
         case self::DAC:
             return Pel::tra('Define arithmetic coding conditioning');
         case self::RST0:
             return Pel::fmt('Restart %d', 0);
         case self::RST1:
             return Pel::fmt('Restart %d', 1);
         case self::RST2:
             return Pel::fmt('Restart %d', 2);
         case self::RST3:
             return Pel::fmt('Restart %d', 3);
         case self::RST4:
             return Pel::fmt('Restart %d', 4);
         case self::RST5:
             return Pel::fmt('Restart %d', 5);
         case self::RST6:
             return Pel::fmt('Restart %d', 6);
         case self::RST7:
             return Pel::fmt('Restart %d', 7);
         case self::DQT:
             return Pel::tra('Define quantization table');
         case self::DNL:
             return Pel::tra('Define number of lines');
         case self::DRI:
             return Pel::tra('Define restart interval');
         case self::DHP:
             return Pel::tra('Define hierarchical progression');
         case self::EXP:
             return Pel::tra('Expand reference component');
         case self::APP0:
             return Pel::fmt('Application segment %d', 0);
         case self::APP1:
             return Pel::fmt('Application segment %d', 1);
         case self::APP2:
             return Pel::fmt('Application segment %d', 2);
         case self::APP3:
             return Pel::fmt('Application segment %d', 3);
         case self::APP4:
             return Pel::fmt('Application segment %d', 4);
         case self::APP5:
             return Pel::fmt('Application segment %d', 5);
         case self::APP6:
             return Pel::fmt('Application segment %d', 6);
         case self::APP7:
             return Pel::fmt('Application segment %d', 7);
         case self::APP8:
             return Pel::fmt('Application segment %d', 8);
         case self::APP9:
             return Pel::fmt('Application segment %d', 9);
         case self::APP10:
             return Pel::fmt('Application segment %d', 10);
         case self::APP11:
             return Pel::fmt('Application segment %d', 11);
         case self::APP12:
             return Pel::fmt('Application segment %d', 12);
         case self::APP13:
             return Pel::fmt('Application segment %d', 13);
         case self::APP14:
             return Pel::fmt('Application segment %d', 14);
         case self::APP15:
             return Pel::fmt('Application segment %d', 15);
         case self::JPG0:
             return Pel::fmt('Extension %d', 0);
         case self::JPG1:
             return Pel::fmt('Extension %d', 1);
         case self::JPG2:
             return Pel::fmt('Extension %d', 2);
         case self::JPG3:
             return Pel::fmt('Extension %d', 3);
         case self::JPG4:
             return Pel::fmt('Extension %d', 4);
         case self::JPG5:
             return Pel::fmt('Extension %d', 5);
         case self::JPG6:
             return Pel::fmt('Extension %d', 6);
         case self::JPG7:
             return Pel::fmt('Extension %d', 7);
         case self::JPG8:
             return Pel::fmt('Extension %d', 8);
         case self::JPG9:
             return Pel::fmt('Extension %d', 9);
         case self::JPG10:
             return Pel::fmt('Extension %d', 10);
         case self::JPG11:
             return Pel::fmt('Extension %d', 11);
         case self::JPG12:
             return Pel::fmt('Extension %d', 12);
         case self::JPG13:
             return Pel::fmt('Extension %d', 13);
         case self::COM:
             return Pel::tra('Comment');
         default:
             return Pel::fmt('Unknown marker: 0x%02X', $m);
     }
 }
Beispiel #21
0
 /**
  * Return the size of components in a given format.
  *
  * @param PelFormat the format.
  *
  * @return the size in bytes needed to store one component with the
  * given format.
  */
 static function getSize($type)
 {
     switch ($type) {
         case self::ASCII:
             return 1;
         case self::BYTE:
             return 1;
         case self::SHORT:
             return 2;
         case self::LONG:
             return 4;
         case self::RATIONAL:
             return 8;
         case self::SBYTE:
             return 1;
         case self::SSHORT:
             return 2;
         case self::SLONG:
             return 4;
         case self::SRATIONAL:
             return 8;
         case self::FLOAT:
             return 4;
         case self::DOUBLE:
             return 8;
         case self::UNDEFINED:
             return 1;
         default:
             return Pel::fmt('Unknown format: 0x%X', $type);
     }
 }
 /**
  * Get the value of an entry as text.
  *
  * The value will be returned in a format suitable for presentation,
  * e.g., rationals will be returned as 'x/y', ASCII strings will be
  * returned as themselves etc.
  *
  * @param
  *            boolean some values can be returned in a long or more
  *            brief form, and this parameter controls that.
  *
  * @return string the value as text.
  */
 public function getText($brief = false)
 {
     if (isset($this->value[0])) {
         $v = $this->value[0];
     }
     switch ($this->tag) {
         case PelTag::FNUMBER:
             // CC (e->components, 1, v);
             return Pel::fmt('f/%.01f', $v[0] / $v[1]);
         case PelTag::APERTURE_VALUE:
             // CC (e->components, 1, v);
             // if (!v_rat.denominator) return (NULL);
             return Pel::fmt('f/%.01f', pow(2, $v[0] / $v[1] / 2));
         case PelTag::FOCAL_LENGTH:
             // CC (e->components, 1, v);
             // if (!v_rat.denominator) return (NULL);
             return Pel::fmt('%.1f mm', $v[0] / $v[1]);
         case PelTag::SUBJECT_DISTANCE:
             // CC (e->components, 1, v);
             // if (!v_rat.denominator) return (NULL);
             return Pel::fmt('%.1f m', $v[0] / $v[1]);
         case PelTag::EXPOSURE_TIME:
             // CC (e->components, 1, v);
             // if (!v_rat.denominator) return (NULL);
             if ($v[0] / $v[1] < 1) {
                 return Pel::fmt('1/%d sec.', $v[1] / $v[0]);
             } else {
                 return Pel::fmt('%d sec.', $v[0] / $v[1]);
             }
             break;
         case PelTag::GPS_LATITUDE:
         case PelTag::GPS_LONGITUDE:
             $degrees = $this->value[0][0] / $this->value[0][1];
             $minutes = $this->value[1][0] / $this->value[1][1];
             $seconds = $this->value[2][0] / $this->value[2][1];
             return sprintf('%s� %s\' %s" (%.2f�)', $degrees, $minutes, $seconds, $degrees + $minutes / 60 + $seconds / 3600);
         default:
             return parent::getText($brief);
     }
 }
 /**
  * Return a text string with the version.
  *
  * @param boolean controls if the output should be brief.  Brief
  * output omits the word 'Version' so the result is just 'Exif x.y'
  * instead of 'Exif Version x.y' if the entry holds information
  * about the Exif version --- the output for FlashPix is similar.
  *
  * @return string the version number with the type of the tag,
  * either 'Exif' or 'FlashPix'.
  */
 function getText($brief = false)
 {
     $v = $this->version;
     /* Versions numbers like 2.0 would be output as just 2 if we don't
      * add the '.0' ourselves. */
     if (floor($this->version) == $this->version) {
         $v .= '.0';
     }
     switch ($this->tag) {
         case PelTag::EXIF_VERSION:
             if ($brief) {
                 return Pel::fmt('Exif %s', $v);
             } else {
                 return Pel::fmt('Exif Version %s', $v);
             }
         case PelTag::FLASH_PIX_VERSION:
             if ($brief) {
                 return Pel::fmt('FlashPix %s', $v);
             } else {
                 return Pel::fmt('FlashPix Version %s', $v);
             }
         case PelTag::INTEROPERABILITY_VERSION:
             if ($brief) {
                 return Pel::fmt('Interoperability %s', $v);
             } else {
                 return Pel::fmt('Interoperability Version %s', $v);
             }
     }
     if ($brief) {
         return $v;
     } else {
         return Pel::fmt('Version %s', $v);
     }
 }
Beispiel #24
0
  function __construct() {
    require_once(dirname(__FILE__) . \'/../../src/PelJpeg.php\');
    parent::__construct(\'PEL %s Tests\');
  }

  function testRead() {
    Pel::clearExceptions();
    Pel::setStrictParsing(false);
    $jpeg = new PelJpeg(dirname(__FILE__) . \'/%s\');
', $test_name, $image_filename, $image_filename);
require_once dirname(__FILE__) . '/../../src/PelJpeg.php';
$jpeg = new PelJpeg($image_filename);
$indent = 2;
jpegToTest('$jpeg', $jpeg);
println();
$exceptions = Pel::getExceptions();
if (count($exceptions) == 0) {
    println('$this->assertTrue(count(Pel::getExceptions()) == 0);');
} else {
    println('$exceptions = Pel::getExceptions();');
    for ($i = 0; $i < count($exceptions); $i++) {
        println('$this->assertIsA($exceptions[%d], \'%s\');', $i, get_class($exceptions[$i]));
        println('$this->assertEqual($exceptions[%d]->getMessage(),', $i);
        println('                   \'%s\');', quote($exceptions[$i]->getMessage()));
    }
}
println('
  }
}
');
/* The test case is finished -- now dump the output as a PHP file. */
Beispiel #25
0
 /**
  * Check if data is valid TIFF data.
  *
  * This will read just enough data from the data window to determine
  * if the data could be a valid TIFF data. This means that the
  * check is more like a heuristic than a rigorous check.
  *
  * @param PelDataWindow $d
  *            the bytes that will be examined.
  *
  * @return boolean true if the data looks like valid TIFF data,
  *         false otherwise.
  *
  * @see PelJpeg::isValid()
  */
 public static function isValid(PelDataWindow $d)
 {
     /* First check that we have enough data. */
     if ($d->getSize() < 8) {
         return false;
     }
     /* Byte order */
     if ($d->strcmp(0, 'II')) {
         $d->setByteOrder(PelConvert::LITTLE_ENDIAN);
     } elseif ($d->strcmp(0, 'MM')) {
         Pel::debug('Found Motorola byte order');
         $d->setByteOrder(PelConvert::BIG_ENDIAN);
     } else {
         return false;
     }
     /* Verify the TIFF header */
     return $d->getShort(2) == self::TIFF_HEADER;
 }
Beispiel #26
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);
Beispiel #27
0
 /**
  * Turn this directory into text.
  *
  * @return string information about the directory, mainly for
  * debugging.
  */
 function __toString()
 {
     $str = Pel::fmt("Dumping IFD %s with %d entries...\n", $this->getName(), count($this->entries));
     foreach ($this->entries as $entry) {
         $str .= $entry->__toString();
     }
     $str .= Pel::fmt("Dumping %d sub IFDs...\n", count($this->sub));
     foreach ($this->sub as $type => $ifd) {
         $str .= $ifd->__toString();
     }
     if ($this->next != null) {
         $str .= $this->next->__toString();
     }
     return $str;
 }
 /**
  * Return a text string with the copyright information.
  *
  * The photographer and editor copyright fields will be returned
  * with a '-' in between if both copyright fields are present,
  * otherwise only one of them will be returned.
  *
  * @param boolean if false, then the strings '(Photographer)' and
  * '(Editor)' will be appended to the photographer and editor
  * copyright fields (if present), otherwise the fields will be
  * returned as is.
  *
  * @return string the copyright information in a string.
  */
 function getText($brief = false)
 {
     if ($brief) {
         $p = '';
         $e = '';
     } else {
         $p = ' ' . Pel::tra('(Photographer)');
         $e = ' ' . Pel::tra('(Editor)');
     }
     if ($this->photographer != '' && $this->editor != '') {
         return $this->photographer . $p . ' - ' . $this->editor . $e;
     }
     if ($this->photographer != '') {
         return $this->photographer . $p;
     }
     if ($this->editor != '') {
         return $this->editor . $e;
     }
     return '';
 }
Beispiel #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);
Beispiel #30
0
 /**
  * Get the value of an entry as text.
  *
  * The value will be returned in a format suitable for presentation,
  * e.g., instead of returning '2' for a {@link
  * PelTag::METERING_MODE} tag, 'Center-Weighted Average' is
  * returned.
  *
  * @param boolean some values can be returned in a long or more
  * brief form, and this parameter controls that.
  *
  * @return string the value as text.
  */
 function getText($brief = false)
 {
     switch ($this->tag) {
         case PelTag::METERING_MODE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Unknown');
                 case 1:
                     return Pel::tra('Average');
                 case 2:
                     return Pel::tra('Center-Weighted Average');
                 case 3:
                     return Pel::tra('Spot');
                 case 4:
                     return Pel::tra('Multi Spot');
                 case 5:
                     return Pel::tra('Pattern');
                 case 6:
                     return Pel::tra('Partial');
                 case 255:
                     return Pel::tra('Other');
                 default:
                     return $this->value[0];
             }
         case PelTag::COMPRESSION:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return Pel::tra('Uncompressed');
                 case 6:
                     return Pel::tra('JPEG compression');
                 default:
                     return $this->value[0];
             }
         case PelTag::PLANAR_CONFIGURATION:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return Pel::tra('chunky format');
                 case 2:
                     return Pel::tra('planar format');
                 default:
                     return $this->value[0];
             }
         case PelTag::SENSING_METHOD:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return Pel::tra('Not defined');
                 case 2:
                     return Pel::tra('One-chip color area sensor');
                 case 3:
                     return Pel::tra('Two-chip color area sensor');
                 case 4:
                     return Pel::tra('Three-chip color area sensor');
                 case 5:
                     return Pel::tra('Color sequential area sensor');
                 case 7:
                     return Pel::tra('Trilinear sensor');
                 case 8:
                     return Pel::tra('Color sequential linear sensor');
                 default:
                     return $this->value[0];
             }
         case PelTag::LIGHT_SOURCE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Unknown');
                 case 1:
                     return Pel::tra('Daylight');
                 case 2:
                     return Pel::tra('Fluorescent');
                 case 3:
                     return Pel::tra('Tungsten (incandescent light)');
                 case 4:
                     return Pel::tra('Flash');
                 case 9:
                     return Pel::tra('Fine weather');
                 case 10:
                     return Pel::tra('Cloudy weather');
                 case 11:
                     return Pel::tra('Shade');
                 case 12:
                     return Pel::tra('Daylight fluorescent');
                 case 13:
                     return Pel::tra('Day white fluorescent');
                 case 14:
                     return Pel::tra('Cool white fluorescent');
                 case 15:
                     return Pel::tra('White fluorescent');
                 case 17:
                     return Pel::tra('Standard light A');
                 case 18:
                     return Pel::tra('Standard light B');
                 case 19:
                     return Pel::tra('Standard light C');
                 case 20:
                     return Pel::tra('D55');
                 case 21:
                     return Pel::tra('D65');
                 case 22:
                     return Pel::tra('D75');
                 case 24:
                     return Pel::tra('ISO studio tungsten');
                 case 255:
                     return Pel::tra('Other');
                 default:
                     return $this->value[0];
             }
         case PelTag::FOCAL_PLANE_RESOLUTION_UNIT:
         case PelTag::RESOLUTION_UNIT:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 2:
                     return Pel::tra('Inch');
                 case 3:
                     return Pel::tra('Centimeter');
                 default:
                     return $this->value[0];
             }
         case PelTag::EXPOSURE_PROGRAM:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Not defined');
                 case 1:
                     return Pel::tra('Manual');
                 case 2:
                     return Pel::tra('Normal program');
                 case 3:
                     return Pel::tra('Aperture priority');
                 case 4:
                     return Pel::tra('Shutter priority');
                 case 5:
                     return Pel::tra('Creative program (biased toward depth of field)');
                 case 6:
                     return Pel::tra('Action program (biased toward fast shutter speed)');
                 case 7:
                     return Pel::tra('Portrait mode (for closeup photos with the background out of focus');
                 case 8:
                     return Pel::tra('Landscape mode (for landscape photos with the background in focus');
                 default:
                     return $this->value[0];
             }
         case PelTag::ORIENTATION:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return Pel::tra('top - left');
                 case 2:
                     return Pel::tra('top - right');
                 case 3:
                     return Pel::tra('bottom - right');
                 case 4:
                     return Pel::tra('bottom - left');
                 case 5:
                     return Pel::tra('left - top');
                 case 6:
                     return Pel::tra('right - top');
                 case 7:
                     return Pel::tra('right - bottom');
                 case 8:
                     return Pel::tra('left - bottom');
                 default:
                     return $this->value[0];
             }
         case PelTag::YCBCR_POSITIONING:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return Pel::tra('centered');
                 case 2:
                     return Pel::tra('co-sited');
                 default:
                     return $this->value[0];
             }
         case PelTag::YCBCR_SUB_SAMPLING:
             //CC (e->components, 2, v);
             if ($this->value[0] == 2 && $this->value[1] == 1) {
                 return 'YCbCr4:2:2';
             }
             if ($this->value[0] == 2 && $this->value[1] == 2) {
                 return 'YCbCr4:2:0';
             }
             return $this->value[0] . ', ' . $this->value[1];
         case PelTag::PHOTOMETRIC_INTERPRETATION:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 2:
                     return 'RGB';
                 case 6:
                     return 'YCbCr';
                 default:
                     return $this->value[0];
             }
         case PelTag::COLOR_SPACE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 1:
                     return 'sRGB';
                 case 2:
                     return 'Adobe RGB';
                 case 0xffff:
                     return Pel::tra('Uncalibrated');
                 default:
                     return $this->value[0];
             }
         case PelTag::FLASH:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0x0:
                     return Pel::tra('Flash did not fire.');
                 case 0x1:
                     return Pel::tra('Flash fired.');
                 case 0x5:
                     return Pel::tra('Strobe return light not detected.');
                 case 0x7:
                     return Pel::tra('Strobe return light detected.');
                 case 0x9:
                     return Pel::tra('Flash fired, compulsory flash mode.');
                 case 0xd:
                     return Pel::tra('Flash fired, compulsory flash mode, return light not detected.');
                 case 0xf:
                     return Pel::tra('Flash fired, compulsory flash mode, return light detected.');
                 case 0x10:
                     return Pel::tra('Flash did not fire, compulsory flash mode.');
                 case 0x18:
                     return Pel::tra('Flash did not fire, auto mode.');
                 case 0x19:
                     return Pel::tra('Flash fired, auto mode.');
                 case 0x1d:
                     return Pel::tra('Flash fired, auto mode, return light not detected.');
                 case 0x1f:
                     return Pel::tra('Flash fired, auto mode, return light detected.');
                 case 0x20:
                     return Pel::tra('No flash function.');
                 case 0x41:
                     return Pel::tra('Flash fired, red-eye reduction mode.');
                 case 0x45:
                     return Pel::tra('Flash fired, red-eye reduction mode, return light not detected.');
                 case 0x47:
                     return Pel::tra('Flash fired, red-eye reduction mode, return light detected.');
                 case 0x49:
                     return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode.');
                 case 0x4d:
                     return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected.');
                 case 0x4f:
                     return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode, return light detected.');
                 case 0x58:
                     return Pel::tra('Flash did not fire, auto mode, red-eye reduction mode.');
                 case 0x59:
                     return Pel::tra('Flash fired, auto mode, red-eye reduction mode.');
                 case 0x5d:
                     return Pel::tra('Flash fired, auto mode, return light not detected, red-eye reduction mode.');
                 case 0x5f:
                     return Pel::tra('Flash fired, auto mode, return light detected, red-eye reduction mode.');
                 default:
                     return $this->value[0];
             }
         case PelTag::CUSTOM_RENDERED:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Normal process');
                 case 1:
                     return Pel::tra('Custom process');
                 default:
                     return $this->value[0];
             }
         case PelTag::EXPOSURE_MODE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Auto exposure');
                 case 1:
                     return Pel::tra('Manual exposure');
                 case 2:
                     return Pel::tra('Auto bracket');
                 default:
                     return $this->value[0];
             }
         case PelTag::WHITE_BALANCE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Auto white balance');
                 case 1:
                     return Pel::tra('Manual white balance');
                 default:
                     return $this->value[0];
             }
         case PelTag::SCENE_CAPTURE_TYPE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Standard');
                 case 1:
                     return Pel::tra('Landscape');
                 case 2:
                     return Pel::tra('Portrait');
                 case 3:
                     return Pel::tra('Night scene');
                 default:
                     return $this->value[0];
             }
         case PelTag::GAIN_CONTROL:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Normal');
                 case 1:
                     return Pel::tra('Low gain up');
                 case 2:
                     return Pel::tra('High gain up');
                 case 3:
                     return Pel::tra('Low gain down');
                 case 4:
                     return Pel::tra('High gain down');
                 default:
                     return $this->value[0];
             }
         case PelTag::SATURATION:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Normal');
                 case 1:
                     return Pel::tra('Low saturation');
                 case 2:
                     return Pel::tra('High saturation');
                 default:
                     return $this->value[0];
             }
         case PelTag::CONTRAST:
         case PelTag::SHARPNESS:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Normal');
                 case 1:
                     return Pel::tra('Soft');
                 case 2:
                     return Pel::tra('Hard');
                 default:
                     return $this->value[0];
             }
         case PelTag::SUBJECT_DISTANCE_RANGE:
             //CC (e->components, 1, v);
             switch ($this->value[0]) {
                 case 0:
                     return Pel::tra('Unknown');
                 case 1:
                     return Pel::tra('Macro');
                 case 2:
                     return Pel::tra('Close view');
                 case 3:
                     return Pel::tra('Distant view');
                 default:
                     return $this->value[0];
             }
         case PelTag::SUBJECT_AREA:
             switch ($this->components) {
                 case 2:
                     return Pel::fmt('(x,y) = (%d,%d)', $this->value[0], $this->value[1]);
                 case 3:
                     return Pel::fmt('Within distance %d of (x,y) = (%d,%d)', $this->value[0], $this->value[1], $this->value[2]);
                 case 4:
                     return Pel::fmt('Within rectangle (width %d, height %d) around (x,y) = (%d,%d)', $this->value[0], $this->value[1], $this->value[2], $this->value[3]);
                 default:
                     return Pel::fmt('Unexpected number of components (%d, expected 2, 3, or 4).', $this->components);
             }
         default:
             return parent::getText($brief);
     }
 }