protected Imager CreateImager(Material material)
        {
            if (material == null || material.File == null)
            {
                throw new CustomArgumentException("Can't create Imager for empty Material!");
            }

            if (_infrastructure.StorageService == null)
            {
                throw new CustomArgumentException("FileStorage Service is not presented!");
            }

            if (material.FileType != FileName.FileType.Image)
            {
                throw new CustomArgumentException("Can't create Imager for not Image Material!");
            }

            // get path for image file
            var materialPath = _infrastructure.GetMaterialPath(material);

            // get image byte array
            var materialData = _infrastructure.StorageService.ReadFile(materialPath);

            // create imager object for image
            return(Imager.Create(materialData));
        }
        public void test_imager_props_foto()
        {
            var    path  = ImageFileName;
            var    path2 = "3.jpg";
            var    path3 = "4.jpg";
            Imager img   = Imager.Create(File.ReadAllBytes(path));


            Debug.WriteLine(img.Info.Title);
            Debug.WriteLine(img.Info.Comment);
            Debug.WriteLine(img.Info.Date == null ? "null" : img.Info.Date.ToString());

            img.Info.Title   = "говое название ";
            img.Info.Comment = "КОИИИИИж'";
            img.Info.Date    = new DateTime(2016, 6, 23, 17, 19, 0);

            File.WriteAllBytes(path, img.Save());

            Debug.WriteLine(img.Info.Title);
            Debug.WriteLine(img.Info.Comment);
            Debug.WriteLine(img.Info.Date == null ? "null" : img.Info.Date.ToString());

            File.WriteAllBytes(path2, img.Save());

            File.WriteAllBytes(path3, img.Resize(200).Save(90));
        }
Beispiel #3
0
        public byte[] CreateImageThumbnail(byte[] image)
        {
            if (image == null)
            {
                throw new CustomArgumentException("Image content can't be empty!");
            }

            var imager = Imager.Create(image);

            return(this.CreateImageThumbnail(imager));
        }