コード例 #1
0
ファイル: SortedPhoto.cs プロジェクト: DmitriyCE/Lab1
        public static void SortPhotoByLocation(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByGeoLocation");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var geolocation = InfoImage.GetLocationPhoto(photo);
                if (geolocation != null)
                {
                    var location = InfoImage.GetLocality(geolocation);
                    if (Directory.Exists(pathNew + $"\\{location}") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, location);
                    }
                    photo.CopyTo(pathNew + $"\\{location}\\{photo.Name}", true);
                }
                else
                {
                    if (Directory.Exists(pathNew + $"\\NoneGeolocation") == false)
                    {
                        sortPhoto.CreateDirectoryOfName(pathNew, "NoneGeolocation");
                    }
                    photo.CopyTo(pathNew + $"\\NoneGeolocation\\{photo.Name}", true);
                }
            }
        }
コード例 #2
0
        public static void RenameImageByData(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoDate_RenameImage");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();

            foreach (var photo in massPhoto)
            {
                photo.CopyTo(pathNew + $"\\{photo.Name.Split('.')[0]}_{InfoImage.ImageDate(photo).ToShortDateString()}.{photo.Name.Split('.')[1]}", true);
            }
        }
コード例 #3
0
ファイル: SortedPhoto.cs プロジェクト: DmitriyCE/Lab1
        public static void SortPhotoByYears(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "PhotoSort_SortPhotoByYear");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();
            var sortPhoto = new SortedPhoto();

            foreach (var photo in massPhoto)
            {
                var datePhoto = InfoImage.ImageDate(photo).ToString("Y");
                if (Directory.Exists(pathNew + $"\\{datePhoto}") == false)
                {
                    sortPhoto.CreateDirectoryOfName(pathNew, datePhoto);
                }
                photo.CopyTo(pathNew + $"\\{datePhoto}\\{photo.Name}", true);
            }
        }
コード例 #4
0
ファイル: DataOnPhoto.cs プロジェクト: DmitriyCE/Lab1
        public static void DateOnTheImage(string path)
        {
            var createDir = new CreateDirectory();
            var pathNew   = createDir.CreateDirectoryOfName(path, "Photo_DateOnTheImage");
            var dirinfo   = new DirectoryInfo(path);
            var massPhoto = dirinfo.GetFiles();

            foreach (var photo in massPhoto)
            {
                Bitmap bitmap       = (Bitmap)Image.FromFile(photo.FullName);
                int    wight        = bitmap.Width;
                int    height       = bitmap.Height;
                PointF TextLocation = new PointF(wight - 500, 200);
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    using (Font arialFont = new Font("Arial", 80, FontStyle.Bold))
                    {
                        graphics.DrawString(InfoImage.ImageDate(photo).ToShortDateString(), arialFont, Brushes.Red, TextLocation);
                    }
                }
                bitmap.Save(pathNew + $"\\{photo.Name}");
            }
        }