예제 #1
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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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}");
            }
        }