Lightweight Image Cropping Plugin with jQuery - Cropbox

File Size: 13.3 KB
Views Total: 11841
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Lightweight Image Cropping Plugin with jQuery - Cropbox

Cropbox is a lightweight jQuery image cropping plugin that creates a viewport around a given image allowing to move, zoom, resize and crop an image.

Basic usage:

1. Add jQuery library together with the jQuery cropbox plugin's JS and CSS files to your html page.

<link href="src/jquery.cropbox.css" rel="stylesheet">
<script src="//"></script>
<script src="src/jquery.cropbox.js"></script>

2. Include the jQuery mousewheel plugin for mouse wheel support.

<script src="//"></script>

3. Create a basic image cropper like this:

<div id="demo" class="cropbox">

  <!-- Crop area -->
  <div class="workarea-cropbox">
      <div class="bg-cropbox">
          <img class="image-cropbox">
          <div class="membrane-cropbox"></div>
      <div class="frame-cropbox">
          <div class="resize-cropbox"></div>

  <!-- Crop buttons -->
  <div class="btn-group">
      <span class="btn btn-primary btn-file">
          <i class="glyphicon glyphicon-folder-open"></i>
          Browse <input type="file" accept="image/*">
      <button type="button" class="btn btn-success btn-crop">
          <i class="glyphicon glyphicon-scissors"></i> Crop
      <button type="button" class="btn btn-warning btn-reset">
          <i class="glyphicon glyphicon-repeat"></i> Reset

  <!-- Cropped image -->
  <div class="cropped panel panel-default">
      <div class="panel-heading"><h3 class="panel-title">Result of cropping</h3></div>
      <div class="panel-body">...</div>

  <!-- Info of cropping -->
  <div class="form-group">
      <label>Info of cropping</label>
      <textarea class="data form-control" rows="5"></textarea>

4. Initialize the image cropper.

  selectors: {
    inputInfo: '#demo',
    inputFile: '#demo input[type="file"]',
    btnCrop: '#demo .btn-crop',
    btnReset: '#demo .btn-reset',
    resultContainer: '#demo .cropped .panel-body',
    messageBlock: '#message'

  imageOptions: {
    class: 'img-thumbnail',
    style: 'margin-right: 5px; margin-bottom: 5px'

  variants: [{
    width: 200,
    height: 200,
    minWidth: 180,
    minHeight: 200,
    maxWidth: 350,
    maxHeight: 350
    width: 150,
    height: 200

  messages: [
      'Crop a middle image.',
      'Crop a small image.'

Change log:


  • removed building scripts. added the event cb.cropped. small fixes.

This awesome jQuery plugin is developed by bupy7. For more Advanced Usages, please check the demo page or visit the official website.