Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.