隐藏页面特效

5.6-团队项目-项目回顾

1、头像上传大小截取问题

头像上传后,若截取大小,则无法进行保存;若不截取大小,则可以进行保存。

System.Drawing.Bitmap

 

 int Width = 200;
        int Height = 200;
        System.Drawing.Image image;
        string FilePath = Server.MapPath("UpFile/") + "woody.jpg";
        image = System.Drawing.Bitmap.FromFile(FilePath);
        Bitmap Img = new Bitmap(Width, Height);
        string newFilePath = Server.MapPath("UpFile/") + "newwoody.jpg";
        System.Drawing.Graphics gp = Graphics.FromImage(Img);
        Rectangle rl = new Rectangle(0, 0, 200, 200);
        gp.DrawImage(image, rl);
        Img.Save(newFilePath);
        Img.Dispose();
        gp.Dispose();
        image.Dispose();

 

2、图片截取插件的版本不匹配问题

function fileSelectHandler() {

// get selected file

var oFile = document.getElementById('image_file').files[0];
// hide all errors
$('.error').hide();

// check for image type (jpg and png are allowed)
var rFilter = /^(image\/jpeg|image\/png)$/i;
if (! rFilter.test(oFile.type)) {
$('.error').html('Please select a valid image file (jpg and png are allowed)').show();
return;
}

// check for file size
if (oFile.size > 2500 * 1024) {
$('.error').html('You have selected too big file, please select a one smaller image file').show();
return;
}

// preview element
var oImage = document.getElementById('preview');

// prepare HTML5 FileReader
var oReader = new FileReader();
oReader.readAsDataURL(oFile);
// oImage.src = null;

oReader.onload = function(e) {

// e.target.result contains the DataURL which we can use as a source of the image
oImage.src = e.target.result;


oImage.onload = function () { // onload event handler


$('.step2').fadeIn(500); //class为step2的显示出来

var sResultFileSize = bytesToSize(oFile.size);
$('#filesize').val(sResultFileSize); //图像大小
$('#filetype').val(oFile.type); //图像类型
$('#filedim').val(oImage.naturalWidth + ' x ' + oImage.naturalHeight); //像素 x * y

// 创建jcrop api和裁剪框的大小
*************************************************************
var jcrop_api, boundx, boundy;//将这里设置为全局变量就可以了
*******************************************************************
 // destroy Jcrop if it is existed
if (typeof jcrop_api != 'undefined')
jcrop_api.destroy();

// initialize Jcrop
$('#preview').Jcrop({
minSize: [32, 32], //最小边框大小
aspectRatio : 1, // 裁剪边框的比例
bgFade: true, // 背景特效
bgOpacity: .3, // 背景透明度
onChange: updateInfo, //边框改变事件
onSelect: updateInfo, //边框选择事件
onRelease: clearInfo //边框释放事件
}, function(){

// use the Jcrop API to get the real image size
var bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];

// Store the Jcrop API in the jcrop_api variable
jcrop_api = this;
});
};
};
// read selected file as DataURL

}

 


__EOF__

本文作者往心。
本文链接https://www.cnblogs.com/lx06/p/14905442.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   往心。  阅读(30)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示