scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 305 forks source link

cannot get cropit to send the actual cropped area #181

Open rdwebdevel opened 8 years ago

rdwebdevel commented 8 years ago

No matter what I try to do, croppit seems bound and determined to save the thumbnail starting from the top left corner of my image. It sets the correct height and width, but the bas64 image is always that top left corner.

Calling with the following:

`` $(function() { $('.image-editor').cropit({

          imageBackground: true,
              imageBackgroundBorderWidth: 10,
              initialZoom: 'image',
              maxZoom: 3,
              type: 'image/jpeg',
              quality: 1,
              minZoom: 'fill',
              onImageLoaded: function() {
                 $('.image-editor').cropit('offset', { x: 0, y: 0 });
              }

      });``

Saving with the following:

` // Move cropped image data to hidden input var imageData = $('.image-editor').cropit('export'); var czoom = $('.image-editor').cropit('zoom');

//$('.image-editor').cropit('exportZoom', (czoom*3));

      $('.hidden-image-data').val(imageData);

      // Print HTTP request params

    var formData = new FormData($('#myform')[0]);

        $.ajax({
           type: 'POST',
           data: formData,
           async: false,
               cache: false,
                   contentType: false,
                   processData: false,

           url: 'upload.php',
           success: function(data){
            alert('Cropped image saved! '+data);
          }

     });          

      // Prevent the form from actually submitting
      return false;`

Please help!