Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active October 30, 2017 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/f99ff3aa0e4362d4d677a62f4b018015 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/f99ff3aa0e4362d4d677a62f4b018015 to your computer and use it in GitHub Desktop.
Examples-GroupDocs.Metadata-for-Java
// For complete examples and data files, please go to https://github.com/groupdocs-metadata/GroupDocs.Metadata-for-Java
public class PhotoParser
{
/**
* <p>
* Absolute path to the photos directory.
* </p>
*/
public final String getPhotosDirectory(){ return auto_PhotosDirectory; }
public final void setPhotosDirectory(String value){ auto_PhotosDirectory = value; }
private String auto_PhotosDirectory;
public PhotoParser(String photosDirectory) throws FileNotFoundException
{
Path path = Paths.get(Common.getStoragePath(photosDirectory));
this.setPhotosDirectory(Common.getStoragePath(photosDirectory));
}
public final String[] filterByCameraManufacturer(String manufacturer)
{
File dir = new File(getPhotosDirectory());
File [] files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".jpg");
}
});
java.util.List<String> result = new ArrayList<String>();
for(File f: files)
{
String filePath = f.getAbsolutePath();
// recognize file
FormatBase format = FormatFactory.recognizeFormat(filePath);
if(format.getType() == DocumentType.Jpeg)
{
JpegFormat jpeg = (JpegFormat)format;
// get exif data
JpegExifInfo exif = (JpegExifInfo)jpeg.getExifInfo();
if (exif != null)
{
if (exif.getMake() == manufacturer)
{
result.add(filePath);
}
}
}
}
return result.toArray(new String[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment