Get started with jquery-jcrop CDN
MIT licensed
JQuery-JCrop is a popular plugin for creating image cropping functionality in web applications.
Tags:- jquery
- crop
Stable version
Copied!
How to start using jquery-jcrop CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with jquery-jcrop CDN - cdnhub.io</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.cdnhub.io/jquery-jcrop/0.9.15/css/Jcrop.css" type="text/css">
<style>
#image {
border: 1px solid #ccc;
height: 300px;
width: 300px;
}
</style>
</head>
<body>
<div class="container mt-5">
<img id="image" src="path/to/your/image.jpg" alt="Image to be cropped">
<div id="jcrop_container"></div>
<button id="save_btn" class="btn btn-primary mt-3">Save</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.cdnhub.io/jquery-jcrop/0.9.15/js/Jcrop.js"></script>
<script>
$(document).ready(function () {
$('#image').Jcrop({
boxWidth: 100,
boxHeight: 100,
aspectRatio: 1,
onSelect: updateCoords
}, function () {
this.setSelect([0, 0, 200, 200]);
});
function updateCoords(c) {
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
}
$('#save_btn').click(function () {
saveCoords();
});
function saveCoords() {
var x = $('#x').val();
var y = $('#y').val();
var w = $('#w').val();
var h = $('#h').val();
console.log('x: ' + x + ', y: ' + y + ', w: ' + w + ', h: ' + h);
}
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!