Skip to content

Commit

Permalink
Improve exif extraction (#84)
Browse files Browse the repository at this point in the history
* Improve exif extraction
  • Loading branch information
Ioseba Palop authored Oct 11, 2019
1 parent 2c948ad commit 4535865
Show file tree
Hide file tree
Showing 88 changed files with 2,741 additions and 17,920 deletions.
1 change: 1 addition & 0 deletions FOCA/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions FOCA/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -733,6 +734,7 @@ public int GetImageToExtension(string extension)
case ".crw":
case ".jpg":
case ".jpeg":
case ".png":
return 32;
case ".svg":
case ".svgz":
Expand Down Expand Up @@ -980,6 +982,12 @@ public void TreeViewProjectAfterSelect(object sender, TreeViewEventArgs e)
NewItemListView("Modified date", f.ModificationDate.ToString(), "Dates");

}
if (e.Node.Nodes["GPS"] != null && e.Node.Nodes["GPS"].Tag is FileMetadata fmd && fmd != null)
{
panelInformation.lvwInformation.Groups.Add("GPS location", "GPS location");

NewItemListView("Location", fmd.GPS.Value, "GPS");
}

SetOtherMetaParentNode(e);

Expand Down Expand Up @@ -1139,7 +1147,7 @@ public void TreeViewProjectAfterSelect(object sender, TreeViewEventArgs e)
{
InitializePanelInformation();

var ed = e.Node.Tag as FileMetadata;
FileMetadata ed = e.Node.Tag as FileMetadata;
if (ed != null)
{
var dicExif = ed.Makernotes;
Expand All @@ -1156,7 +1164,7 @@ public void TreeViewProjectAfterSelect(object sender, TreeViewEventArgs e)

try
{
var pc = new PictureBox();
PictureBox pc = new PictureBox();
using (var ms = new MemoryStream(ed.Thumbnail))
{
pc.Image = new Bitmap(ms);
Expand All @@ -1182,6 +1190,23 @@ public void TreeViewProjectAfterSelect(object sender, TreeViewEventArgs e)
}
}
}
else if (e.Node.Text == "GPS" && IsDocumentNode(e.Node.Parent))
{
InitializePanelInformation();

FileMetadata ed = e.Node.Tag as FileMetadata;
if (ed != null)
{
panelInformation.lvwInformation.Groups.Add("GPS location", "GPS location");
NewItemListView("DMS", ed.GPS.Value, "GPS location");
string longitude = ed.GPS.Longitude.ToString("0.000000", CultureInfo.InvariantCulture);
string latitude = ed.GPS.Latitude.ToString("0.000000", CultureInfo.InvariantCulture);
NewItemListView("Longitude", longitude, "GPS location");
NewItemListView("Latitude", latitude, "GPS location");
NewItemListView("Altitude", ed.GPS.Altitude, "GPS location");
NewItemListView("Google maps url", $"https://www.google.com/maps/search/?api=1&query={latitude},{longitude}", "GPS location");
}
}
else if (e.Node == TreeView.Nodes[UpdateGUI.TreeViewKeys.KProject.ToString()].Nodes[UpdateGUI.TreeViewKeys.KMetadata.ToString()].Nodes["Metadata Summary"].Nodes["Users"])
{
InitializeInformationPanel();
Expand Down
4,818 changes: 2,419 additions & 2,399 deletions FOCA/FormMain.resx

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions FOCA/PanelMetadataSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,15 @@ internal void AddDocumentNodes(MetaExtractor doc, TreeNode trnParentNode, FileMe
}
}));
}

if (originalMetadata.GPS != null)
{
methodsToInvoke.Add(new Action(() =>
{
TreeNode gps = trnParentNode.Nodes.Add("GPS", "GPS", 122, 122);
gps.Tag = originalMetadata;
}));
}
}

Program.FormMainInstance.TreeView.Invoke(new MethodInvoker(() =>
Expand Down
4 changes: 4 additions & 0 deletions MetadataExtractCore/Diagrams/FileMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class FileMetadata

public string Model { get; set; }

public GeoLocation GPS { get; set; }

public FileMetadata()
{
this.Applications = new HashSet<Application>();
Expand All @@ -81,6 +83,7 @@ public bool HasMetadata()
this.History.Count > 0 ||
this.Printers.Count > 0 ||
this.Passwords.Count > 0 ||
this.Makernotes.Count > 0 ||
!String.IsNullOrWhiteSpace(this.Category) ||
!String.IsNullOrWhiteSpace(this.Codification) ||
!String.IsNullOrWhiteSpace(this.Comments) ||
Expand All @@ -96,6 +99,7 @@ public bool HasMetadata()
!String.IsNullOrWhiteSpace(this.Template) ||
!String.IsNullOrWhiteSpace(this.Title) ||
!String.IsNullOrWhiteSpace(this.UserInfo) ||
this.GPS != null ||
this.VersionNumber > 0 ||
this.EditTime > 0 ||
this.Dates.CreationDate.HasValue ||
Expand Down
17 changes: 17 additions & 0 deletions MetadataExtractCore/Diagrams/GeoLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace MetadataExtractCore.Diagrams
{
public class GeoLocation : MetadataValue
{
public double Latitude { get; set; }

public double Longitude { get; set; }

public string Altitude { get; set; }

public GeoLocation(string dmsLocation, double longitude, double latitude) : base(dmsLocation)
{
this.Longitude = longitude;
this.Latitude = latitude;
}
}
}
5 changes: 3 additions & 2 deletions MetadataExtractCore/Metadata/DocumentExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace MetadataExtractCore.Extractors
{
public abstract class DocumentExtractor : IDisposable
{
public static readonly string[] SupportedExtensions = new string[] { ".sxw", ".odt", ".ods", ".odg", ".odp", ".docx", ".xlsx", ".pptx", ".ppsx", ".doc", ".xls", ".ppt", ".pps", ".pdf", ".wpd", ".raw", ".cr2", ".crw", ".jpg", ".jpeg", ".svg", ".svgz", ".indd", ".rdp", ".ica" };
public static readonly string[] SupportedExtensions = new string[] { ".sxw", ".odt", ".ods", ".odg", ".odp", ".docx", ".xlsx", ".pptx", ".ppsx", ".doc", ".xls", ".ppt", ".pps", ".pdf", ".wpd", ".raw", ".cr2", ".crw", ".jpg", ".jpeg", ".png", ".svg", ".svgz", ".indd", ".rdp", ".ica" };

protected MemoryStream fileStream;
protected FileMetadata foundMetadata;
Expand Down Expand Up @@ -80,7 +80,8 @@ public static DocumentExtractor Create(string extension, Stream file)
case ".crw":
case ".jpg":
case ".jpeg":
document = new EXIFDocument(file, extension);
case ".png":
document = new EXIFDocument(file);
break;
case ".svg":
case ".svgz":
Expand Down
Loading

0 comments on commit 4535865

Please sign in to comment.