<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="css/imgareaselect-default.css">
<buttom class="btn upload">upload</buttom>
</head>
<body>
<input type="file" name="" id="file-upload">
<div class="img"> </div>
</body>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.imgareaselect.js"></script>
<script>
window.URL = window.URL || window.webkitURL;
$("body").on("change", "#file-upload", function() {
var file = $("#file-upload").get(0).files[0];
var img = new Image();
img.src = window.URL.createObjectURL(file);
img.onload = function(e) {
window.URL.revokeObjectURL(this.src);
load_select();
}
$(".img").append(img);
});
$("body").on("click", ".upload", function() {
var jq = $(".img > img");
var img = jq.attr("src");
var xPos = jq.attr("data-xpos");
var yPos = jq.attr("data-ypos");
var width = jq.attr("data-width");
var height = jq.attr("data-height");
console.log("the range of pic is");
console.log("x: %s, y: %s, w: %s, h: %s", xPos, yPos, width, height);
});
function load_select() {
var jq = $(".img > img");
jq.imgAreaSelect({
selectionColor: "blue",
aspectRatio: "4:3",
selectionOpacity: 0.2,
onSelectEnd: function(img, selection) {
jq.attr("data-xpos", selection.x1);
jq.attr("data-ypos", selection.y1);
jq.attr("data-width", selection.width);
jq.attr("data-height", selection.height);
}
});
}
</script>
</html>

插件:http://odyniec.net/projects/imgareaselect/

上传图片+浏览+裁切 Demo(无后台处理部分)的更多相关文章

  1. 无后台的网站 内容暂存json

    当网站无后台时,将数据暂存储为json文档,然后通过调用json文件获取数据填充前端页面 存储json格式的文件 [ { "id": 1, "cat": &qu ...

  2. 富文本编辑器上传图片需要配置js,后台代码

    富文本编辑器上传图片需要配置js,后台代码

  3. arcgisserver成功发布服务后,浏览服务,无地图显示

    软件:ArcMap10.2,ArcgisCatalog10.2 方法:ArcMap10.2添加数据库连接,成功登陆数据库后,拖拽目标图层至Map窗口,对各个图层进行符号化设置 ArcCatalog中找 ...

  4. 一周一个小demo — 前端后台的交互实例

    这一周呢,本K在大神的指导下,完成了一个利用ajax与php文件上传处理相结合的一个留言板功能的小实例,下面就让本K来带大家瞅瞅如何实现这一种功能. 一.界面概览 首先我们来看一下这个小demo的具体 ...

  5. ArcGIS Server浏览地图服务无响应原因分析说明

    1.问题描述 从4月17号下午5时起,至18号晚9点,客户单位部分通过ArcGIS Server发布的地图服务(该部分地图服务的数据源为数据库SJZX)无法加载浏览,表现为长时间无响应.同时,通过Ar ...

  6. 2、微信小程序之弹幕的实现(无后台)

    对弹幕功能主要利用环信来实现的,读者也许对环信这个东西很陌生,请先自行了解这环信再来看这文章. 环信开发文档:http://docs.easemob.com/im/400webimintegratio ...

  7. 1、微信小程序----弹幕的实现(无后台)

    小程序刚刚出来,现在网上的demo是多,但是要找到一个自己需要的却不容易.今天跟大家分享自己写的一个弹幕功能. 先来一张效果图: 我的思路是这样的,先用<switch>标签确定是否打开弹幕 ...

  8. 无后台应用 Stash Backend

    Stash Backend 是Github上的开源项目 https://github.com/gaboratorium/stash,目的在于提供一套方便使用.方便部署的后台应用.特别适合为Web前端和 ...

  9. 微信小程序-游记分享(无后台)

    游记分享 博客班级 https://edu.cnblogs.com/campus/zjcsxy/SE2020 作业要求 https://edu.cnblogs.com/campus/zjcsxy/SE ...

随机推荐

  1. android学习——popupWindow 在指定位置上的显示

    先看效果图,免得浪费大家时间,看是不是想要的效果 . 直接上代码 ,核心方法. [java] view plaincopy private void showPopupWindow(View pare ...

  2. Android_listView_BaseAdapter

    layout.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x ...

  3. MySql安装步骤详解,MySql的root密码设置,启动MySql服务。

    1.下载mysql安装包,并解压,双击mysql-5.6.24-winx64.msi 2.点击下一步 3.选择custom 4.选择安装内容和位置,5个安装内容要选择will be installed ...

  4. Azure CLI (一)如何安装和配置Azure CLI

    什么是Azure CLI 快速安装 Azure 命令行界面 (Azure CLI),以便使用一组基于 shell 的开源命令在 Azure 中创建和管理资源. 步骤 1:安装 . 登录https:// ...

  5. linux 软件安装各种方法

    一   简单介绍 1.软件安装卸载,分几种情况: A:RPM包 这种软件包就像windows的EXE安装文件一样,各种文件已经编译好,并打了包,哪个文件该放到哪个文件夹,都指定好了,安装非常方便,在图 ...

  6. js中的call及apply的运用

    格式: obj.call(thisObj, arg1, arg2, ...); 参数为字符 obj.apply(thisObj, [arg1, arg2, ...]); 参数为数组 例一:sub函数赋 ...

  7. 修改Atom 隐藏.gitignore忽略的文件/文件夹的配置

    参考链接:.gitignored files are hidden from tree view regardless of setting 假如Atom打开的文件夹有.gitignore 文件,会隐 ...

  8. css 去除input 获取焦点的蓝色边框

    input{ outline:0px; }

  9. Asp.net MVC 4 视图相关和其他

    @{ Layout = “…”} To define layout page Equivalent to asp.net master-page 要定义相当于ASP.NET母版页的页面布局 @mode ...

  10. Microsoft Word 的键盘快捷方式

    Microsoft Word 的键盘快捷方式 全部显示 全部隐藏 本帮助文章中描述的键盘快捷方式适用于美式键盘布局.其他键盘布局的键可能与美式键盘上的键 不完全对应. 注释   本文不介绍如何为宏或自 ...