Exemple #1
0
        //protected override void FinishedNotify()
        //{

        //}

        protected override void SpecificProcessing()
        {
            IExtractor <Image> extractor = ExtractorFactory.CreateExtractor("datetime");

            foreach (var item in _filesInfo)
            {
                try
                {
                    using (Image img = Image.FromFile(item))
                    {
                        string creationTime = extractor.Extract(img, 0x9003).Replace("\0", string.Empty).Replace('/', '_').Replace(':', '_');// GetImageDate(img);

                        File.Copy(item, _destinationPath.FullName + "\\" + Path.GetFileNameWithoutExtension(item) + "_"
                                  + (string.IsNullOrWhiteSpace(creationTime) ? (File.GetCreationTime(item).ToString().Replace(':', '_').Replace('/', '_')) : creationTime)
                                  + Path.GetExtension(item), true);
                    }
                }
                catch (OutOfMemoryException ex)
                {
                    string msg = ex.Message;
                }
                catch (FileNotFoundException ex)
                {
                    string msg = ex.Message;
                }
                catch (ArgumentException ex)
                {
                    string msg = ex.Message;
                }
                //Thread.Sleep();
            }
            Console.WriteLine();
            Console.WriteLine("RENAME DATETIME FINISHED!!!!");
            Console.WriteLine();
        }
        protected override void SpecificProcessing()
        {
            IExtractor <Image> extractor = ExtractorFactory.CreateExtractor("datetime");

            foreach (var item in _filesInfo)
            {
                using (FileStream readfs = new FileStream(item, FileMode.Open)) //filestream to read image
                {
                    using (Image img = Image.FromStream(readfs))
                    {
                        using (Graphics grph = Graphics.FromImage(img))
                            using (Font font = new Font(new FontFamily("Arial"), (float)(0.015 * img.Height)))
                                using (SolidBrush sbrush = new SolidBrush(Color.Black)) //using graphical tools
                                {
                                    //need to add verifying of min image size and correct label font size and area
                                    RectangleF rect = new RectangleF(new PointF((int)(img.Width - 385), (int)(img.Height * 0.001)), new SizeF(385, (int)(img.Height * .02))); //put a rectangle in top right corner of the image
                                    grph.FillRectangle(Brushes.White, rect);                                                                                                  //fill rectangle with white color because label will be black

                                    string res = extractor.Extract(img, 0x9003);                                                                                              //get information from image
                                    grph.DrawString(res, font, sbrush, rect);                                                                                                 //draw label on the image
                                }


                        using (FileStream writefs = new FileStream(_destinationPath.FullName + "\\" + Path.GetFileName(item), FileMode.OpenOrCreate))
                        {
                            ImageFormat imgFormat = ImageFormat.Bmp;
                            switch (Path.GetFileName(item))
                            {
                            case ".jpg":
                                imgFormat = ImageFormat.Jpeg;
                                break;

                            case ".jpeg":
                                imgFormat = ImageFormat.Jpeg;
                                break;

                            case ".png":
                                imgFormat = ImageFormat.Png;
                                break;

                            case ".gif":
                                imgFormat = ImageFormat.Gif;
                                break;
                            }
                            img.Save(writefs, imgFormat);  //save image in new folder
                        }
                    }
                }
            }
            Console.WriteLine();
            Console.WriteLine("ADD LABEL FINISHED!!!!");
            Console.WriteLine();
        }
 protected XSSFExcelExtractor GetExtractor(String sampleName)
 {
     ExtractorFactory.SetAllThreadsPreferEventExtractors(false);
     ExtractorFactory.SetThreadPrefersEventExtractors(false);
     try
     {
         return((XSSFExcelExtractor)ExtractorFactory.CreateExtractor(HSSFTestDataSamples.OpenSampleFileStream(sampleName)));
     }
     catch (Exception e)
     {
         throw new RuntimeException(e);
     }
 }
        protected override void SpecificProcessing()
        {
            IExtractor <Image> extractor = ExtractorFactory.CreateExtractor("datetime");

            DateTime dtextr;

            foreach (var item in _filesInfo)
            {
                using (FileStream fs = new FileStream(item, FileMode.Open))
                {
                    using (Image img = Image.FromStream(fs))
                    {
                        string data = extractor.Extract(img, 0x9003).Split(' ')[0].Replace(':', '/');   //extracting datetime get from there year/month/day and parse it to dateTime and get year

                        DateTime.TryParse(data, out dtextr);

                        if (dtextr == DateTime.MinValue)
                        {
                            dtextr = File.GetCreationTime(item);
                        }

                        if (!Directory.Exists(_destinationPath.FullName + "\\" + dtextr.Year))
                        {
                            Directory.CreateDirectory(Path.Combine(_destinationPath.FullName, dtextr.Year + ""));
                        }
                        try
                        {
                            File.Copy(item, _destinationPath.FullName + "\\" + dtextr.Year + "\\" + Path.GetFileName(item), true);
                        }
                        catch (Exception ex)
                        {
                            string s = ex.Message;
                        }
                        //File.Copy(item, _destinationPath.FullName + "\\" + dtextr.Year + "\\" + Path.GetFileName(item), true);
                    }
                }
            }
            Console.WriteLine();
            Console.WriteLine("SORT BY YEARS FINISHED!!!!");
            Console.WriteLine();
        }
Exemple #5
0
        protected override void SpecificProcessing()
        {
            IExtractor <Image> extractor = ExtractorFactory.CreateExtractor("coordinates");

            foreach (var item in _filesInfo)
            {
                using (Image img = Image.FromFile(item))
                {
                    //var data = extractor.Extract(img, 0).Split(' ');

                    ExifLib.ExifReader reader = new ExifLib.ExifReader(item);
                    double             lat;
                    reader.GetTagValue(ExifLib.ExifTags.GPSLatitude, out lat);
                    double lon;
                    reader.GetTagValue(ExifLib.ExifTags.GPSLongitude, out lon);

                    //double alt = Double.Parse( data[0]);
                    //double lon = Double.Parse(data[1]);
                }
            }
        }
Exemple #6
0
 protected XSSFEventBasedExcelExtractor GetExtractor(String sampleName)
 {
     ExtractorFactory.SetAllThreadsPreferEventExtractors(true);
     return((XSSFEventBasedExcelExtractor)ExtractorFactory.CreateExtractor(HSSFTestDataSamples.OpenSampleFileStream(sampleName)));
 }