jQuery Mobile中的压缩图像上传 [英] Compressed Image Uploading in jQuery Mobile

查看:79
本文介绍了jQuery Mobile中的压缩图像上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我用jquery mobile创建了一个网页。

我在页面中有文件上传选项,其中as所有手机都有自己的图像捕捉尺寸。

但我需要压缩图像并存储在FTP中,请给我解决方案

Dear Friends,

I have created a webpage using jquery mobile.
I have file upload option in the page, where as all the mobile will have its own image capturing size.
But I need to compress the image and store in FTP, please give me you solution

推荐答案

使用下面的代码,我们可以压缩图像。



Using below code we can compress the image.

using (var image = Image.FromStream(sourcePath))
{
//var newWidth = (int)(image.Width * scaleFactor);
//var newHeight = (int)(image.Height * scaleFactor);
var newWidth = 500;
var newHeight = 250;
var thumbnailImg = new Bitmap(newWidth, newHeight);
var thumbGraph = Graphics.FromImage(thumbnailImg);
thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbGraph.DrawImage(image, imageRectangle);
//thumbnailImg.Dispose();
thumbnailImg.Save(targetPath, image.RawFormat);
}


这篇关于jQuery Mobile中的压缩图像上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆