I'm trying to use cropper.js for the following scenario:
- User uploads image via form input
- User crops the image down resulting in crop a
- Crop a is shown as a new image
- User crops the image further resulting in crop b
- Both cropped images are sent to the server
For some reason when I put the base64 data urls generated via my code into a decoder or image tag I get either a broken image or a tiny sliver of the image. Here are the relevant parts of my code:
Html exists on the page including an image tag: with id=originalImg
cropper = $('#originalImg'); cropper.cropper({ dragMode: 'crop', checkCrossOrigin: true, guides: false });
User uses the cropper.js interface to select a crop, then clicks a button which gets the cropped section with:
cropper.cropper('getCroppedCanvas').toDataURL('image/jpeg');
I then replace the originalImg tag with a new image tag with the source from step two, and then do step 1 and 2 above again.
Any idea why the resulting base64 seems wonky?