public virtual void SetUp()
 {
     Com.Drew.Metadata.Metadata metadata = ExifReaderTest.ProcessBytes("Tests/Data/nikonMakernoteType1.jpg.app1");
     _nikonDirectory      = metadata.GetFirstDirectoryOfType <NikonType1MakernoteDirectory>();
     _exifSubIFDDirectory = metadata.GetFirstDirectoryOfType <ExifSubIFDDirectory>();
     _exifIFD0Directory   = metadata.GetFirstDirectoryOfType <ExifIFD0Directory>();
     _thumbDirectory      = metadata.GetFirstDirectoryOfType <ExifThumbnailDirectory>();
 }
 public virtual void SetUp()
 {
     Com.Drew.Metadata.Metadata metadata = ExifReaderTest.ProcessBytes("Tests/Data/nikonMakernoteType2b.jpg.app1");
     _nikonDirectory      = metadata.GetFirstDirectoryOfType <NikonType2MakernoteDirectory>();
     _exifIFD0Directory   = metadata.GetFirstDirectoryOfType <ExifIFD0Directory>();
     _exifSubIFDDirectory = metadata.GetFirstDirectoryOfType <ExifSubIFDDirectory>();
     _thumbDirectory      = metadata.GetFirstDirectoryOfType <ExifThumbnailDirectory>();
     NUnit.Framework.Assert.IsNotNull(_nikonDirectory);
     NUnit.Framework.Assert.IsNotNull(_exifSubIFDDirectory);
 }
Esempio n. 3
0
        public virtual void TestResolution()
        {
            Com.Drew.Metadata.Metadata metadata           = ExifReaderTest.ProcessBytes("Tests/Data/withUncompressedRGBThumbnail.jpg.app1");
            ExifThumbnailDirectory     thumbnailDirectory = metadata.GetFirstDirectoryOfType <ExifThumbnailDirectory>();

            NUnit.Framework.Assert.IsNotNull(thumbnailDirectory);
            Sharpen.Tests.AreEqual(72, thumbnailDirectory.GetInt(ExifThumbnailDirectory.TagXResolution));
            ExifIFD0Directory exifIFD0Directory = metadata.GetFirstDirectoryOfType <ExifIFD0Directory>();

            NUnit.Framework.Assert.IsNotNull(exifIFD0Directory);
            Sharpen.Tests.AreEqual(216, exifIFD0Directory.GetInt(ExifIFD0Directory.TagXResolution));
        }
        public virtual void TestDifferenceImageAndThumbnailOrientations()
        {
            // This metadata contains different orientations for the thumbnail and the main image.
            // These values used to be merged into a single directory, causing errors.
            // This unit test demonstrates correct behaviour.
            Com.Drew.Metadata.Metadata metadata           = ProcessBytes("Tests/Data/repeatedOrientationTagWithDifferentValues.jpg.app1");
            ExifIFD0Directory          ifd0Directory      = metadata.GetFirstDirectoryOfType <ExifIFD0Directory>();
            ExifThumbnailDirectory     thumbnailDirectory = metadata.GetFirstDirectoryOfType <ExifThumbnailDirectory>();

            NUnit.Framework.Assert.IsNotNull(ifd0Directory);
            NUnit.Framework.Assert.IsNotNull(thumbnailDirectory);
            Sharpen.Tests.AreEqual(1, ifd0Directory.GetInt(ExifIFD0Directory.TagOrientation));
            Sharpen.Tests.AreEqual(8, thumbnailDirectory.GetInt(ExifThumbnailDirectory.TagOrientation));
        }
 public static JpegDirectory ProcessBytes(string filePath)
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     new JpegReader().Extract(FileUtil.ReadBytes(filePath), metadata, JpegSegmentType.Sof0);
     JpegDirectory directory = metadata.GetFirstDirectoryOfType<JpegDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     return directory;
 }
 public static AdobeJpegDirectory ProcessBytes([NotNull] string filePath)
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     new AdobeJpegReader().Extract(new SequentialByteArrayReader(FileUtil.ReadBytes(filePath)), metadata);
     AdobeJpegDirectory directory = metadata.GetFirstDirectoryOfType<AdobeJpegDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     return directory;
 }
Esempio n. 7
0
        public static JpegDirectory ProcessBytes(string filePath)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new JpegReader().Extract(FileUtil.ReadBytes(filePath), metadata, JpegSegmentType.Sof0);
            JpegDirectory directory = metadata.GetFirstDirectoryOfType <JpegDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
        public static AdobeJpegDirectory ProcessBytes([NotNull] string filePath)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new AdobeJpegReader().Extract(new SequentialByteArrayReader(FileUtil.ReadBytes(filePath)), metadata);
            AdobeJpegDirectory directory = metadata.GetFirstDirectoryOfType <AdobeJpegDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
 public static GifHeaderDirectory ProcessBytes([NotNull] string file)
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     InputStream stream = new FileInputStream(file);
     new GifReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
     stream.Close();
     GifHeaderDirectory directory = metadata.GetFirstDirectoryOfType<GifHeaderDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     return directory;
 }
 public virtual void TestExtract()
 {
     sbyte[] app2Bytes = FileUtil.ReadBytes("Tests/Data/iccDataInvalid1.jpg.app2");
     // ICC data starts after a 14-byte preamble
     sbyte[] icc = TestHelper.SkipBytes(app2Bytes, 14);
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     new IccReader().Extract(new ByteArrayReader(icc), metadata);
     IccDirectory directory = metadata.GetFirstDirectoryOfType<IccDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
 }
Esempio n. 11
0
        public virtual void TestExtract()
        {
            sbyte[] app2Bytes = FileUtil.ReadBytes("Tests/Data/iccDataInvalid1.jpg.app2");
            // ICC data starts after a 14-byte preamble
            sbyte[] icc = TestHelper.SkipBytes(app2Bytes, 14);
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new IccReader().Extract(new ByteArrayReader(icc), metadata);
            IccDirectory directory = metadata.GetFirstDirectoryOfType <IccDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
        }
Esempio n. 12
0
        public static BmpHeaderDirectory ProcessBytes([NotNull] string file)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            InputStream stream = new FileInputStream(file);

            new BmpReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
            stream.Close();
            BmpHeaderDirectory directory = metadata.GetFirstDirectoryOfType <BmpHeaderDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
 public static PsdHeaderDirectory ProcessBytes([NotNull] string file)
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     InputStream stream = new FileInputStream(new FilePath(file));
     try
     {
         new PsdReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
     }
     catch (Exception e)
     {
         stream.Close();
         throw;
     }
     PsdHeaderDirectory directory = metadata.GetFirstDirectoryOfType<PsdHeaderDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     return directory;
 }
Esempio n. 14
0
        public static PsdHeaderDirectory ProcessBytes([NotNull] string file)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            InputStream stream = new FileInputStream(new FilePath(file));

            try
            {
                new PsdReader().Extract(new Com.Drew.Lang.StreamReader(stream), metadata);
            }
            catch (Exception e)
            {
                stream.Close();
                throw;
            }
            PsdHeaderDirectory directory = metadata.GetFirstDirectoryOfType <PsdHeaderDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
Esempio n. 15
0
        /// <summary>Serializes the XmpDirectory component of <code>Metadata</code> into an <code>OutputStream</code></summary>
        /// <param name="os">Destination for the xmp data</param>
        /// <param name="data">populated metadata</param>
        /// <returns>serialize success</returns>
        public static bool Write(OutputStream os, Com.Drew.Metadata.Metadata data)
        {
            XmpDirectory dir = data.GetFirstDirectoryOfType <XmpDirectory>();

            if (dir == null)
            {
                return(false);
            }
            XMPMeta meta = dir.GetXMPMeta();

            try
            {
                SerializeOptions so = new SerializeOptions().SetOmitPacketWrapper(true);
                XMPMetaFactory.Serialize(meta, os, so);
            }
            catch (XMPException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                return(false);
            }
            return(true);
        }
 private void Validate(Com.Drew.Metadata.Metadata metadata)
 {
     Com.Drew.Metadata.Directory directory = metadata.GetFirstDirectoryOfType <ExifSubIFDDirectory>();
     NUnit.Framework.Assert.IsNotNull(directory);
     Sharpen.Tests.AreEqual("80", directory.GetString(ExifSubIFDDirectory.TagIsoEquivalent));
 }