通过预加载在图片加载前读取图片尺寸
/***************************************************************************************
* 图片头数据加载就绪获取图片尺寸
* @version 2011.05.27
* @author TangBin
* @see http://www.planeart.cn/?p=1121
* @param {String} 图片路径
* @param {Function} 尺寸就绪
* @param {Function} 加载完毕 (可选)
* @param {Function} 加载错误 (可选)
yundanran_imageSize('http://b.zol-img.com.cn/desk/bizhi/image/5/2560x1600/1409624254331.jpg', function ()
{
alert('size ready: width=' + this.width + '; height=' + this.height);
});
*******************************************************************************************/
var yundanran_imageSize = (function ()
{
var list = [], intervalId = null,
// 用来执行队列
tick = function () {
var i = 0;
for (; i < list.length; i++) {
list[i].end ? list.splice(i--, 1) : list[i]();
};
!list.length && stop();
},
// 停止所有定时器队列
stop = function () {
clearInterval(intervalId);
intervalId = null;
};
return function (url, ready, load, error) {
var onready, width, height, newWidth, newHeight,
img = new Image();
img.src = url;
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
ready.call(img);
load && load.call(img);
return;
};
width = img.width;
height = img.height;
// 加载错误后的事件
img.onerror = function () {
error && error.call(img);
onready.end = true;
img = img.onload = img.onerror = null;
};
// 图片尺寸就绪
onready = function () {
newWidth = img.width;
newHeight = img.height;
if (newWidth !== width || newHeight !== height ||
// 如果图片已经在其他地方加载可使用面积检测
newWidth * newHeight > 1024
) {
ready.call(img);
onready.end = true;
};
};
onready();
// 完全加载完毕的事件
img.onload = function () {
// onload在定时器时间差范围内可能比onready快
// 这里进行检查并保证onready优先执行
!onready.end && onready();
load && load.call(img);
// IE gif动画会循环执行onload,置空onload即可
img = img.onload = img.onerror = null;
};
// 加入队列中定期执行
if (!onready.end) {
list.push(onready);
// 无论何时只允许出现一个定时器,减少浏览器性能损耗
if (intervalId === null) intervalId = setInterval(tick, 40);
};
};
})();
http://qianduanblog.com/post/js-learning-10-image-reload-size.html
很好的个人博客
http://qianduanblog.com/
http://code.ciaoca.com/
无以言表
莫可名状
又
难以启齿
oh, shit
IIS提示参数错误
可能原因是应用程序池出现问题,新建一个名称为 DefaultAppPool 的应用程序池,即可。
AlloyImage 图像处理引擎
http://alloyteam.github.io/AlloyPhoto/
1.图层功能,提供图层的添加,删除,交换图层顺序等功能,且包含与PS相对应的17种图层混合模式
2.图像的基本调节功能,包括亮度、对比度,色相、饱和度、明度调节
3.多种滤镜功能,去色、反相、高斯模糊、锐化、浮雕效果、查找边缘、马赛克、腐蚀等
4.处理后文件的保存,处理完成之后,可以将文件输出为base64形式间接使用和保存
5.高级组合效果,如素描,lomo,复古,素描等复合效果 如一个素描效果的实现
jQuery Validation Engine 表单验证
中文:http://code.ciaoca.com/jquery/validation_engine/
https://github.com/posabsolute/jQuery-Validation-Engine
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/
学习这种通用的验证方式,不需要每个表单都那么麻烦地写一次验证
jQuery cxSelect 联动下拉菜单
中文:http://code.ciaoca.com/jquery/cxSelect/
https://github.com/ciaoca/cxSelect
jQuery Wookmark 瀑布流布局
中文:http://code.ciaoca.com/jquery/wookmark/demo/
http://www.wookmark.com/jquery-plugin
https://github.com/GBKS/Wookmark-jQuery
js生成二维码、条形码
QRCode.js 生成二维码
中文文档:http://code.ciaoca.com/javascript/qrcode/
http://github.com/davidshimjs/qrcodejs
jquery-barcode.js 生成条形码
http://www.cnblogs.com/yjmyzz/p/jquery-barcode.html
http://barcode-coder.com/en/barcode-jquery-plugin-201.html
<script>
var barcodeSettings = {
output:'css', //可选值:css/bmp/svg/canvas(后三种在IE9以下无效)
bgColor: '#ffffff', //背景色
color: '#000000', //前景色
barWidth: 2, //每单元宽度
barHeight: 50, //条码高度,对二维条码无效
moduleSize: 5, //仅类型为datamatrix(二维条码)时有效
posX: 5, //output=canvas时有效
posY: 5, //output=canvas时有效
addQuietZone: 1 //仅类型为datamatrix(二维条码)时有效
},
type='code39', //码制,可选值:ean8/ean1/upc/std25/int25/code11/code39/code93/code128/codebar/msi/datamatrix
str='0123456789'; //条码内容
$("#barcode").html("").show().barcode(str, type, barcodeSettings);
</script>
Exif.js 读取图像的元数据
中文文档:http://code.ciaoca.com/javascript/exif-js/
https://github.com/jseidelin/exif-js
