Exemplo n.º 1
0
        public ImagesDpiDetail GetImagesDpiConfigByCategoryType(string categoryType)
        {
            if (categoryType.IsNullOrEmpty())
            {
                return(null);
            }
            ImagesDpiDetail imagesDpiDetail = null;
            var             allImageDpi     = GetImagesDpiConfig();

            if (allImageDpi != null)
            {
                imagesDpiDetail = allImageDpi.FirstOrDefault(o => o.id == categoryType);
            }
            return(imagesDpiDetail);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="originalImagePath"></param>
        /// <param name="imagesDpiDetail"></param>
        /// <param name="fileType">image/video</param>
        public Tuple <int, int> MakeThumbnail(string originalImagePath, ImagesDpiDetail imagesDpiDetail, string fileType = "image")
        {
            Tuple <int, int> wh = Tuple.Create(0, 0);

            if (imagesDpiDetail != null)
            {
                imagesDpiDetail.SectionItems.ForEach(s =>
                {
                    //生成的缩略图的路径格式是:原图路径 + “-”+ dpi + 后缀
                    string desPath = originalImagePath.Insert(originalImagePath.LastIndexOf('.'), "-" + (s.dpi ?? imagesDpiDetail.def));
                    //ThumbnailHelper.GenerateImage(originalImagePath, desPath, s.width, s.height);
                    if (!System.IO.File.Exists(desPath))
                    {
                        wh = ThumbnailHelper.GenerateImage2(originalImagePath, desPath, s.width, s.height, fileType);
                    }
                });
            }
            return(wh);
        }