Esempio n. 1
0
        private bool IsCropValueFullImage(R161Image image)
        {
            if (_cropX == 0 && _cropY == 0 && _cropW == image.Width && _cropH == image.Height)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        private string SaveImage()
        {
            if (!DoesImageNeedHandling)
            {
                return(_originalPath);
            }

            var image = new R161Image(Server.MapPath(_originalPath));

            // TODO: Temporary fix for selecting full image, try to do this without loading the image first..
            if (IsCropValueFullImage(image))
            {
                return(_originalPath);
            }

            if (_hasCropValues)
            {
                image.Crop(_cropX, _cropY, _cropW, _cropH);
            }

            if (_width > 0 || _height > 0)
            {
                image.Resize(_width, _height);
            }

            var imagePath  = GetNewImagePath();
            var serverPath = Server.MapPath(imagePath);

            if (File.Exists(serverPath))
            {
                var originalServerPath = Server.MapPath(_originalPath);

                if (File.GetLastWriteTime(originalServerPath) < File.GetLastWriteTime(serverPath))
                {
                    return(imagePath);
                }

                File.Delete(serverPath);
            }

            // TODO: Config quality
            image.SaveJpg(Server.MapPath(imagePath), 90);

            return(imagePath);
        }