public void ResizeThumbnail(Photo photo, ImageResizeUtil imageResizeUtil)
        {
            Image thumbnail = imageResizeUtil.GetThumbnail();

            photo.ThumbHeight = thumbnail.Height;
            photo.ThumbWidth  = thumbnail.Width;

            string        thumbPath = _galleryPathBuilder.GetThumbDirectory(photo.Album);
            DirectoryInfo directory = new DirectoryInfo(thumbPath);

            if (!directory.Exists)
            {
                directory.Create();
            }

            thumbnail.Save(_galleryPathBuilder.GetThumbPath(photo), ImageFormat.Jpeg);
        }
Exemplo n.º 2
0
        /// <summary>
        /// On settings changes
        /// </summary>
        public void ResizeAllImages(int maxImageWidth, int maxThumbWidth)
        {
            _albumService = GetAlbumService();
            _photoService = GetPhotoService();

            foreach (Album album in _albumService.GetAlbumList(false))
            {
                foreach (Photo photo in _photoService.GetPhotoList(album.Id))
                {
                    _fileService.DeleteFile(_galleryPathBuilder.GetThumbPath(photo));
                    //_fileService.DeleteFile(_galleryPathBuilder.GetPath(photo));

                    Image image = Image.FromStream(_fileService.ReadFile(_galleryPathBuilder.GetPhotoOriginPath(photo)));

                    ImageResizeUtil imageResizeUtilThumb = new ImageResizeUtil(image, maxThumbWidth);
                    //ImageResizeUtil imageResizeUtil = new ImageResizeUtil(image, maxImageWidth);

                    //_photoService.ResizeImage(photo, imageResizeUtil);
                    _photoService.ResizeThumbnail(photo, imageResizeUtilThumb);

                    _photoService.SavePhotoInfo(photo);
                }
            }
        }