예제 #1
0
        public static void CreateResizedImage(int ImageID, string fullPrefix, string thumbPrefix, int fullSize, int thumbSize, Page page)
        {
            string UploadName = "";

            if (ImageID > 0)
            {
                BEImages DSImages;
                BPImages bpImages = new BPImages();
                DSImages = bpImages.SelectByID(ImageID);
                BEImages.tbl_ImagesRow image = DSImages.tbl_Images[0];

                if (DSImages.tbl_Images.Count > 0)
                    UploadName = image.ImageName;

            }

            if (UploadName != null && UploadName != "")
            {
                string path = System.Configuration.ConfigurationManager.AppSettings["UploadsPath"];
                ImageResizer imgRes = new ImageResizer(page);
                if (!imgRes.GenerateResizedImages(@path + UploadName, @path, thumbSize, fullSize, fullPrefix, thumbPrefix))
                {
                    //throw new Exception(imgRes.ResizeErrorMessage);
                }
            }
        }
예제 #2
0
        public static void CreateResizedImage(int imageID, int maxSize, int maxWidth, int maxHeight, string prefix, Page page, bool widthPriority, bool heightPriority)
        {
            string imageFileName = "";

            if (imageID > 0)
            {
                BPImages bpImages = new BPImages();
                BEImages dsImages = bpImages.SelectByID(imageID);

                if (dsImages.tbl_Images.Count > 0)
                    imageFileName = dsImages.tbl_Images[0].ImageName;

            }

            if (imageFileName != "")
            {
                string savePath = System.Configuration.ConfigurationManager.AppSettings["UploadsPath"];
                string imageFilePath;
                bool resizedImageExists = true;

                //Handle prefix with or without underscore
                prefix = prefix.TrimEnd('_');

                imageFilePath = @savePath + prefix + "_" + imageFileName;

                if (!File.Exists(page.Server.MapPath(imageFilePath)))
                {
                    ImageResizer resizer = new ImageResizer(page);
                    if (maxSize > 0)
                    {
                        resizedImageExists = resizer.GenerateResizedImages(@savePath + imageFileName, @savePath, 0, maxSize, prefix, "");
                    }
                    else if (maxWidth > 0 && maxHeight > 0)
                    {
                        resizedImageExists = resizer.GenerateResizedImages(@savePath + imageFileName, @savePath, 0, maxWidth, maxHeight, prefix, "", widthPriority, heightPriority);
                    }
                }

                if (!resizedImageExists)
                {
                    //throw new Exception(imgRes.ResizeErrorMessage);
                }
            }
        }