コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="Com.Drew.Imaging.Jpeg.JpegProcessingException"/>
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                System.Environment.Exit(1);
            }
            string filePath = args[0];

            if (!new FilePath(filePath).Exists())
            {
                System.Console.Error.Println("File does not exist");
                PrintUsage();
                System.Environment.Exit(1);
            }
            ICollection <JpegSegmentType> segmentTypes = new HashSet <JpegSegmentType>();

            for (int i = 1; i < args.Length; i++)
            {
                JpegSegmentType segmentType = JpegSegmentType.ValueOf(args[i].ToUpper());
                if (!segmentType.canContainMetadata)
                {
                    System.Console.Error.Printf("WARNING: Segment type %s cannot contain metadata so it may not be necessary to extract it%n", segmentType);
                }
                segmentTypes.Add(segmentType);
            }
            if (segmentTypes.Count == 0)
            {
                // If none specified, use all that could reasonably contain metadata
                Sharpen.Collections.AddAll(segmentTypes, JpegSegmentType.canContainMetadataTypes);
            }
            JpegSegmentData segmentData = JpegSegmentReader.ReadSegments(new FilePath(filePath), segmentTypes.AsIterable());

            SaveSegmentFiles(filePath, segmentData);
        }