Пример #1
0
        private void FixNoPhotoImage()
        {
            string   path = @"c:\Temp\NoPhoto300.png";
            string   key  = "NoPhoto";
            DateTime now  = DateTime.Now;

            using (Stream stream = File.OpenRead(path))
            {
                Image image = Image.FromStream(stream);

                var newBlob300 = ImageManager.GetResizedImageBlob(image, 300, 0);
                File.WriteAllBytes(@"c:\VoteImages\Profile300\" + key + ".png", newBlob300);
                PoliticiansImagesBlobs.UpdateProfile300(newBlob300, key);
                PoliticiansImagesBlobs.UpdateProfileOriginal(newBlob300, key);

                var newBlob200 = ImageManager.GetResizedImageBlob(image, 200, 0);
                File.WriteAllBytes(@"c:\VoteImages\Profile200\" + key + ".png", newBlob200);
                PoliticiansImagesBlobs.UpdateProfile200(newBlob200, key);

                var newBlob100 = ImageManager.GetResizedImageBlob(image, 100, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot100\" + key + ".png", newBlob100);
                PoliticiansImagesBlobs.UpdateHeadshot100(newBlob100, key);

                var newBlob75 = ImageManager.GetResizedImageBlob(image, 75, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot75\" + key + ".png", newBlob75);
                PoliticiansImagesBlobs.UpdateHeadshot75(newBlob75, key);

                var newBlob50 = ImageManager.GetResizedImageBlob(image, 50, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot50\" + key + ".png", newBlob50);
                PoliticiansImagesBlobs.UpdateHeadshot50(newBlob50, key);

                var newBlob35 = ImageManager.GetResizedImageBlob(image, 35, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot35\" + key + ".png", newBlob35);
                PoliticiansImagesBlobs.UpdateHeadshot35(newBlob35, key);

                var newBlob25 = ImageManager.GetResizedImageBlob(image, 25, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot25\" + key + ".png", newBlob25);
                PoliticiansImagesBlobs.UpdateHeadshot25(newBlob25, key);

                var newBlob20 = ImageManager.GetResizedImageBlob(image, 20, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot20\" + key + ".png", newBlob20);
                PoliticiansImagesBlobs.UpdateHeadshot20(newBlob20, key);

                var newBlob15 = ImageManager.GetResizedImageBlob(image, 15, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot15\" + key + ".png", newBlob15);
                PoliticiansImagesBlobs.UpdateHeadshot15(newBlob15, key);

                PoliticiansImagesData.UpdateHeadshotDate(now, key);
                PoliticiansImagesData.UpdateHeadshotResizeDate(now, key);
                PoliticiansImagesData.UpdateProfileOriginalDate(now, key);

                AppendStatusText("Complete");
            }
        }
Пример #2
0
        private void FixHeadshots(string key)
        {
            byte[] originalBlob = null;
            var    logTable     = LogPoliticiansImagesHeadshot.GetLatestData(key);

            if (logTable.Count > 0)
            {
                originalBlob = logTable[0].HeadshotOriginal;
            }
            else
            {
                originalBlob = PoliticiansImagesBlobs.GetProfileOriginal(key);
            }
            if (originalBlob != null)
            {
                MemoryStream memoryStream = new MemoryStream(originalBlob);
                Image        image        = Image.FromStream(memoryStream);

                var newBlob100 = ImageManager.GetResizedImageBlobAsJpg(image, 100, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot100\" + key + ".jpg", newBlob100);
                PoliticiansImagesBlobs.UpdateHeadshot100(newBlob100, key);

                var newBlob75 = ImageManager.GetResizedImageBlobAsJpg(image, 75, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot75\" + key + ".jpg", newBlob75);
                PoliticiansImagesBlobs.UpdateHeadshot75(newBlob75, key);

                var newBlob50 = ImageManager.GetResizedImageBlobAsJpg(image, 50, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot50\" + key + ".jpg", newBlob50);
                PoliticiansImagesBlobs.UpdateHeadshot50(newBlob50, key);

                var newBlob35 = ImageManager.GetResizedImageBlobAsJpg(image, 35, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot35\" + key + ".jpg", newBlob35);
                PoliticiansImagesBlobs.UpdateHeadshot35(newBlob35, key);

                var newBlob25 = ImageManager.GetResizedImageBlobAsJpg(image, 25, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot25\" + key + ".jpg", newBlob25);
                PoliticiansImagesBlobs.UpdateHeadshot25(newBlob25, key);

                var newBlob20 = ImageManager.GetResizedImageBlobAsJpg(image, 20, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot20\" + key + ".jpg", newBlob20);
                PoliticiansImagesBlobs.UpdateHeadshot20(newBlob20, key);

                var newBlob15 = ImageManager.GetResizedImageBlobAsJpg(image, 15, 0);
                File.WriteAllBytes(@"c:\VoteImages\Headshot15\" + key + ".jpg", newBlob15);
                PoliticiansImagesBlobs.UpdateHeadshot15(newBlob15, key);

                AppendStatusText("processed: {0}", key);
            }
            else
            {
                AppendStatusText("no original: {0}", key);
            }
        }