// note that we also have EXIF metadata that can be extracted

        // this is problematic since it ties this class to ScaledImage
        //
        public void AddThumbs(List <Thumbnail> thumbsToGenerate)
        {
            // read metadata and if the orientation is 90 cw or 90 ccw, perform the rotation
            // todo, refactor the tag processing into its own function, as AddThumbs should do just that
            Image imgPhotoToRotate = Image.FromFile(Filename);

            var exif = new ExifTagCollection(Filename);

            // todo, use other fields such as artist and exposure data and to populate related fields?

            var PropertyItems = imgPhotoToRotate.PropertyItems;
            // to
            var orientation = exif.Where(ex => ex.FieldName == "Orientation").FirstOrDefault();

            // if no orinentation property exists, then the camera figured out the correct height and width (eg cell phone cam, with accelerometer)
            // or if the orientation is reported as "normal" no need to rotate
            if (orientation != null &&
                orientation.Value != "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.")
            {
                int angle = 0;
                if (orientation.Value == "The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.")
                {
                    // rotate 90 degrees, this seems to be most common with camera that sense the orientation but somehow
                    // keep width to be the larger dimension and height the smaller, as in a point and shoot
                    angle = 90;
                }
                else if (orientation.Value == "The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.")
                {
                    angle = 270;
                }
                Image imgPhoto = ImageProcessor.RotateImage(imgPhotoToRotate, angle);
                foreach (var pi in imgPhotoToRotate.PropertyItems)
                {
                    // todo, create symbolic constants for Id values
                    // copy properties, except for orientation, which we set to "normal"
                    // i.e. "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."
                    if (pi.Id == 0x112)
                    {
                        ushort normal = 1;
                        pi.Value = BitConverter.GetBytes(normal);
                    }
                    imgPhoto.SetPropertyItem(pi);
                }
                imgPhotoToRotate.Dispose();
                imgPhoto.Save(Filename, ImageFormat.Jpeg);
            }

            // here I want to set the orientation to "1" or normal after rotating it
            // imgPhotoToRotate.SetPropertyItem(PropertyItems[0]);

            //

            // get the standard thumbs
            foreach (var th in thumbsToGenerate)
            {
                ScaledImage si = new ScaledImage(th, this);
                si.Process();
            }
        }
        public void SetupThumbnails()
        {
            var db = new GalleryContext();

            //db.Thumbnails.Where(t => t.Description == "medium");

            var thumbs = from t in db.Thumbnails where t.MaxHeight == 600 select t;

            var tu = thumbs.First();

               // var tu = db.Thumbnails.();

            //Thumbnail tn = new Thumbnail();
            //tn.Description = "medium";
            //tn.MaxWidth = 600;
            //db.Thumbnails.Add(tn);
            //db.Thumbnails.SaveChanges();

            GalleryImage master = new GalleryImage();
            master.Filename = @"C:\Users\Ken\Documents\GitHub\SimplePhotoGallery\SimplePhotoGallery\Images\img_0519.jpg";
            db.Images.Add(master);

            var mediumThumb = new ScaledImage(tu, master);

            // this adds the medium thumb to the ProcessedImages collection
            mediumThumb.Process();

            // todo: add initialization code to ScaledImage to pass in BaseImage and Thumbnail
            //master.CreateThumbnail(tu, "medium");
            db.Images.Add(mediumThumb);

            db.SaveChanges();
        }
        // note that we also have EXIF metadata that can be extracted

        // this is problematic since it ties this class to ScaledImage
        // 
        public void AddThumbs(List<Thumbnail> thumbsToGenerate)
        {
            // read metadata and if the orientation is 90 cw or 90 ccw, perform the rotation
            // todo, refactor the tag processing into its own function, as AddThumbs should do just that
            Image imgPhotoToRotate = Image.FromFile(Filename);

            var exif = new ExifTagCollection(Filename);

            // todo, use other fields such as artist and exposure data and to populate related fields?

            var PropertyItems = imgPhotoToRotate.PropertyItems;
            // to
            var orientation = exif.Where(ex => ex.FieldName == "Orientation").FirstOrDefault();
            // if no orinentation property exists, then the camera figured out the correct height and width (eg cell phone cam, with accelerometer)
            // or if the orientation is reported as "normal" no need to rotate
            if (orientation != null &&
                orientation.Value != "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.")
            {
                int angle = 0;
                if (orientation.Value == "The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.")
                {
                    // rotate 90 degrees, this seems to be most common with camera that sense the orientation but somehow
                    // keep width to be the larger dimension and height the smaller, as in a point and shoot
                    angle = 90;
                }
                else if (orientation.Value ==  "The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.")
                {
                    angle = 270;
                }
                Image imgPhoto = ImageProcessor.RotateImage(imgPhotoToRotate, angle);
                foreach(var pi in imgPhotoToRotate.PropertyItems)
                {
                    // todo, create symbolic constants for Id values
                    // copy properties, except for orientation, which we set to "normal"
                    // i.e. "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."
                    if (pi.Id == 0x112)
                    {
                        ushort normal = 1;
                        pi.Value = BitConverter.GetBytes(normal);
                    }
                    imgPhoto.SetPropertyItem(pi);
                }
                imgPhotoToRotate.Dispose();
                imgPhoto.Save(Filename, ImageFormat.Jpeg);

            }

            // here I want to set the orientation to "1" or normal after rotating it
            // imgPhotoToRotate.SetPropertyItem(PropertyItems[0]);

            //

            // get the standard thumbs
            foreach (var th in thumbsToGenerate)
            {
                ScaledImage si = new ScaledImage(th, this);
                si.Process();
            }
        }