private static int Main(string[] args) { var workingDirectory = new DirectoryInfo(CurrentPath); var exifTool = new ExifTool(new ExifToolOptions { ExifToolPath = "/usr/bin/vendor_perl/exiftool" }); var exifWrapper = new ExifWrapper(exifTool); var rootImageHandler = new RootImageHandler(exifWrapper); var fromIPhoneOld = CommandExtensions.Create( "from-iphone-old", "Converts a dump from iPhone into a date-based directory structure", dryRun => FromIPhoneOld.Run(workingDirectory, dryRun)); var fromIPhone = CommandExtensions.CreateWithOutput( "from-iphone", "Converts a dump from iPhone into a date-based directory structure", (dryRun, output) => { new FromIPhone(exifWrapper) .Run(workingDirectory, output, dryRun); }); var fixExif = CommandExtensions.Create( "fix-exif", "Set all the missing Exif dates in Exif in a directory, inferring the missing dates from directory names", dryRun => { new FixExif(rootImageHandler).Run(workingDirectory, dryRun); }); var removeDuplicateJpg = CommandExtensions.Create( "remove-duplicate-jpg", "Remove the JPG files that duplicate equivalent HEIC images", dryRun => RemoveDuplicateJpg.Run(workingDirectory, dryRun) ); var separateIPhone5 = CommandExtensions.CreateWithOutput( "identify-iphone5", "Identify which photos have been taken with iPhone 5", (dryRun, output) => { new IdentifyIPhone5(exifWrapper) .Run(workingDirectory, dryRun); }); var rootCommand = new RootCommand { new Option("--version", "The current version of this tool"), fromIPhoneOld, fromIPhone, fixExif, removeDuplicateJpg, separateIPhone5 }; rootCommand.Handler = CommandHandler.Create(Version.VersionHandler); return(rootCommand.Invoke(args)); }
internal FixExif(RootImageHandler rootImageHandler) { _rootImageHandler = rootImageHandler; _commandBuilder = new CommandBuilder(new List <ICondition> { new BothDefined(_rootImageHandler), new NothingDefined(), new OnlyExifDefined(), new OnlyFileSystemDefined(_rootImageHandler) }); }
private static MappableImage ToMappableImage(FileInfo fileInfo, RootImageHandler rootImageHandler) { try { return(MappableImage.From(fileInfo, rootImageHandler)); } catch (Exception) { Console.WriteLine($"Failure: unable to convert {fileInfo.FullName}"); throw; } }
internal static IEnumerable <MappableImage> GetImages(this DirectoryInfo workingDirectory, RootImageHandler rootImageHandler) => workingDirectory .AllFiles() .Select(fileInfo => ToMappableImage(fileInfo, rootImageHandler));
public BothDefined(RootImageHandler rootImageHandler) { _rootImageHandler = rootImageHandler; }
internal UpdateExifDate(MappableImage mappableImage, RootImageHandler rootImageHandler) { _mappableImage = mappableImage; _rootImageHandler = rootImageHandler; }
public OnlyFileSystemDefined(RootImageHandler rootImageHandler) { _rootImageHandler = rootImageHandler; }