public void GetMetadata(FileItem fileItem)
        {
            try
            {
                PhotoUtils.WaitForFile(fileItem.FileName);
                Exiv2Helper exiv2Helper = new Exiv2Helper();
                exiv2Helper.Load(fileItem);

                if (fileItem.FileInfo.ExifTags.ContainName("Exif.Image.Orientation"))
                {
                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "bottom, right")
                    {
                        fileItem.AutoRotation = 2;
                    }

                    //if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "top, left")
                    //    writeableBitmap = writeableBitmap.Rotate(180);

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "right, top")
                    {
                        fileItem.AutoRotation = 1;
                    }

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "left, bottom")
                    {
                        fileItem.AutoRotation = 3;
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error loading metadata ", exception);
            }
        }
Example #2
0
        public void GetMetadata(FileItem fileItem)
        {
            Exiv2Helper exiv2Helper = new Exiv2Helper();

            try
            {
                exiv2Helper.Load(fileItem);
            }
            catch (Exception exception)
            {
                Log.Error("Error loading metadata ", exception);
            }
        }
Example #3
0
        public void GetMetadata(BitmapFile file, WriteableBitmap writeableBitmap)
        {
            Exiv2Helper exiv2Helper = new Exiv2Helper();

            try
            {
                exiv2Helper.Load(file.FileItem.FileName, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight);
                file.Metadata.Clear();
                foreach (var exiv2Data in exiv2Helper.Tags)
                {
                    file.Metadata.Add(new DictionaryItem()
                    {
                        Name = exiv2Data.Value.Tag, Value = exiv2Data.Value.Value
                    });
                }
                if (ServiceProvider.Settings.ShowFocusPoints)
                {
                    writeableBitmap.Lock();
                    foreach (Rect focuspoint in exiv2Helper.Focuspoints)
                    {
                        DrawRect(writeableBitmap, (int)focuspoint.X, (int)focuspoint.Y,
                                 (int)(focuspoint.X + focuspoint.Width),
                                 (int)(focuspoint.Y + focuspoint.Height), Colors.Aqua,
                                 ServiceProvider.Settings.LowMemoryUsage ? 2 : 7);
                    }
                    writeableBitmap.Unlock();
                }

                if (exiv2Helper.Tags.ContainsKey("Exif.Image.Orientation") && !file.FileItem.IsRaw)
                {
                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "bottom, right")
                    {
                        writeableBitmap = writeableBitmap.Rotate(180);
                    }

                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "right, top")
                    {
                        writeableBitmap = writeableBitmap.Rotate(90);
                    }

                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "left, bottom")
                    {
                        writeableBitmap = writeableBitmap.Rotate(270);
                    }
                }

                if (ServiceProvider.Settings.RotateIndex != 0)
                {
                    switch (ServiceProvider.Settings.RotateIndex)
                    {
                    case 1:
                        writeableBitmap = writeableBitmap.Rotate(90);
                        break;

                    case 2:
                        writeableBitmap = writeableBitmap.Rotate(180);
                        break;

                    case 3:
                        writeableBitmap = writeableBitmap.Rotate(270);
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error loading metadata ", exception);
            }

            writeableBitmap.Freeze();
            file.DisplayImage = writeableBitmap;
            file.InfoLabel    = Path.GetFileName(file.FileItem.FileName);
            file.InfoLabel   += String.Format(" | {0}x{1}", exiv2Helper.Width, exiv2Helper.Height);
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureTime"))
            {
                file.InfoLabel += " | E " + exiv2Helper.Tags["Exif.Photo.ExposureTime"].Value;
            }
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FNumber"))
            {
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FNumber"].Value;
            }
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ISOSpeedRatings"))
            {
                file.InfoLabel += " | ISO " + exiv2Helper.Tags["Exif.Photo.ISOSpeedRatings"].Value;
            }
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureBiasValue"))
            {
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.ExposureBiasValue"].Value;
            }
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FocalLength"))
            {
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FocalLength"].Value;
            }
        }
Example #4
0
        public void GetMetadata(FileItem fileItem)
        {
            try
            {
                PhotoUtils.WaitForFile(fileItem.FileName);
                Exiv2Helper exiv2Helper = new Exiv2Helper();
                exiv2Helper.Load(fileItem);

                if (fileItem.FileInfo.ExifTags.ContainName("Exif.Image.Orientation"))
                {
                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "bottom, right")
                        fileItem.AutoRotation = 2;

                    //if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "top, left")
                    //    writeableBitmap = writeableBitmap.Rotate(180);

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "right, top")
                        fileItem.AutoRotation = 1;

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "left, bottom")
                        fileItem.AutoRotation = 3;
                }

            }
            catch (Exception exception)
            {
                Log.Error("Error loading metadata ", exception);
            }
        }
        public void GetMetadata(BitmapFile file, WriteableBitmap writeableBitmap)
        {
            Exiv2Helper exiv2Helper = new Exiv2Helper();
            try
            {
                exiv2Helper.Load(file.FileItem.FileName, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight);
                file.Metadata.Clear();
                foreach (var exiv2Data in exiv2Helper.Tags)
                {
                    file.Metadata.Add(new DictionaryItem() {Name = exiv2Data.Value.Tag, Value = exiv2Data.Value.Value});
                }
                if (ServiceProvider.Settings.ShowFocusPoints)
                {
                    writeableBitmap.Lock();
                    foreach (Rect focuspoint in exiv2Helper.Focuspoints)
                    {
                        DrawRect(writeableBitmap, (int) focuspoint.X, (int) focuspoint.Y,
                                 (int) (focuspoint.X + focuspoint.Width),
                                 (int) (focuspoint.Y + focuspoint.Height), Colors.Aqua,
                                 ServiceProvider.Settings.LowMemoryUsage ? 2 : 7);
                    }
                    writeableBitmap.Unlock();
                }

                if (exiv2Helper.Tags.ContainsKey("Exif.Image.Orientation") && !file.FileItem.IsRaw)
                {
                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "bottom, right")
                        writeableBitmap = writeableBitmap.Rotate(180);

                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "right, top")
                        writeableBitmap = writeableBitmap.Rotate(90);

                    if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "left, bottom")
                        writeableBitmap = writeableBitmap.Rotate(270);
                }

                if (ServiceProvider.Settings.RotateIndex != 0)
                {
                    switch (ServiceProvider.Settings.RotateIndex)
                    {
                        case 1:
                            writeableBitmap = writeableBitmap.Rotate(90);
                            break;
                        case 2:
                            writeableBitmap = writeableBitmap.Rotate(180);
                            break;
                        case 3:
                            writeableBitmap = writeableBitmap.Rotate(270);
                            break;
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error loading metadata ", exception);
            }

            writeableBitmap.Freeze();
            file.DisplayImage = writeableBitmap;
            file.InfoLabel = Path.GetFileName(file.FileItem.FileName);
            file.InfoLabel += String.Format(" | {0}x{1}", exiv2Helper.Width, exiv2Helper.Height);
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureTime"))
                file.InfoLabel += " | E " + exiv2Helper.Tags["Exif.Photo.ExposureTime"].Value;
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FNumber"))
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FNumber"].Value;
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ISOSpeedRatings"))
                file.InfoLabel += " | ISO " + exiv2Helper.Tags["Exif.Photo.ISOSpeedRatings"].Value;
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureBiasValue"))
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.ExposureBiasValue"].Value;
            if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FocalLength"))
                file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FocalLength"].Value;
        }
Example #6
0
 public void GetMetadata(FileItem fileItem)
 {
     Exiv2Helper exiv2Helper = new Exiv2Helper();
     try
     {
         exiv2Helper.Load(fileItem);
     }
     catch (Exception exception)
     {
         Log.Error("Error loading metadata ", exception);
     }
 }