Exemplo n.º 1
0
        public static string ProcessMemberPhoto(Member member, int PhotoCollectionID, Image image, DateTime TakenDT, bool SnappedFromMobile)
        {
            string GlobalWebID = UniqueID.NewWebID();
            string FileName    = GlobalWebID + @".jpg";

            Bitmap bmp = (Bitmap)image;

            try
            {
                EXIFextractor exif = new EXIFextractor(ref bmp, string.Empty);

                if (exif.DTTaken.Year != 1900)
                {
                    TakenDT = exif.DTTaken;
                }
            }
            catch { }


            Photo photo = new Photo();

            photo.Active            = true;
            photo.Mobile            = SnappedFromMobile;
            photo.MemberID          = member.MemberID;
            photo.WebPhotoID        = GlobalWebID;
            photo.PhotoCollectionID = PhotoCollectionID;
            photo.TakenDT           = TakenDT;
            photo.CreatedDT         = DateTime.Now;

            // create the large photo
            // just store the large image.. dont make a resource record
            System.Drawing.Image MainImage = Photo.ResizeTo800x600(image);
            string Savepath = member.NickName + @"\" + "plrge" + @"\" + FileName;

            Photo.SaveToDiskNoCompression(MainImage, Savepath);

            //create the medium
            photo.PhotoResourceFile = new ResourceFile();
            photo.PhotoResourceFile.WebResourceFileID = GlobalWebID;
            photo.PhotoResourceFile.ResourceType      = (int)ResourceFileType.PhotoLarge;
            photo.PhotoResourceFile.Path     = member.NickName + "/" + "pmed" + "/";
            photo.PhotoResourceFile.FileName = FileName;
            photo.PhotoResourceFile.Save();
            System.Drawing.Image MediumImage = Photo.Resize480x480(MainImage);
            Photo.SaveToDisk(MediumImage, photo.PhotoResourceFile.SavePath);

            //create the thumbnail
            photo.ThumbnailResourceFile = new ResourceFile();
            photo.ThumbnailResourceFile.WebResourceFileID = GlobalWebID;
            photo.ThumbnailResourceFile.ResourceType      = (int)ResourceFileType.PhotoThumbnail;
            photo.ThumbnailResourceFile.Path     = member.NickName + "/" + "pthmb" + "/";
            photo.ThumbnailResourceFile.FileName = FileName;
            photo.ThumbnailResourceFile.Save();


            System.Drawing.Image ThumbnailImage = Photo.ScaledCropTo121x91(MediumImage);


            Photo.SaveToDisk(ThumbnailImage, photo.ThumbnailResourceFile.SavePath);

            // attached the resource ids to the photos
            photo.ThumbnailResourceFileID = photo.ThumbnailResourceFile.ResourceFileID;
            photo.PhotoResourceFileID     = photo.PhotoResourceFile.ResourceFileID;

            photo.Save();

            // update the number of photos
            MemberProfile memberProfile = member.MemberProfile[0];

            memberProfile.NumberOfPhotos++;
            memberProfile.Save();

            return(photo.WebPhotoID);
        }