コード例 #1
0
        /// <summary>
        /// 生成标准图片
        /// </summary>
        /// <param name="fileIdentity"></param>
        /// <param name="newFileName"></param>
        public static void CreateStandardImages(string fileIdentity, string newFileName)
        {
            if (ImageList.Count == 0)
            {
                return;
            }
            var result = FileUploadManager.FileExists(fileIdentity);

            if (!result)
            {
                return;
            }
            var   filePath    = FileUploadManager.GetFilePhysicalFullPath(fileIdentity);
            Image uploadImage = Image.FromFile(filePath);

            //判断是否为标准图片
            if (!ImageUtility.CheckImagePixels(uploadImage))
            {
                uploadImage.Dispose();//后面的zoomauto会删除的,资源要提前释放
                //重命名文件
                var bytes     = FileUploadManager.GetFileData(fileIdentity);
                var imageHelp = new ImageUtility {
                    SavePath = filePath
                };
                imageHelp.ZoomAuto(bytes, 640, 480);
            }
        }