Beispiel #1
0
        public PhotoService GetPhotoService()
        {
            if (_photoService == null)
            {
                _photoService = new PhotoService(this);
            }

            return(_photoService);
        }
Beispiel #2
0
        public bool CheckPhoto(string name)
        {
            if (name.Contains("-origin.jpg"))
            {
                return(false);
            }
            if (name.Contains("-thumb.jpg"))
            {
                return(false);
            }
            ICriteria criteria = _sessionManager.OpenSession().CreateCriteria(typeof(Photo))
                                 .Add(Expression.Eq("FileName", PhotoService.CreateServerFilename(name)))
                                 .SetMaxResults(1);

            return(criteria.List().Count == 0);
        }
Beispiel #3
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);
                }
            }
        }