-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with cropping rotated image #668
Comments
Same issue |
This bug appears to have been introduced in version 2.6.3. Downgrading to 2.6.2 fixes this issue. |
We are experiencing the same problem in version 2.6.4, only the picture gets filled with white pixels. Downgrading to 2.6.2 fixed it. |
I have the same problem version 2.6.4, picture filled with black pixels. |
works on 2.4.1 |
Hi, |
It looks like this was fixed in version 2.6.5. |
I can still reproduce this issue in Chrome on Windows 10, using the latest version (2.6.5). Here's the relevant code: var $croppie = $('.js-croppie');
var $placeholder = $('.js-croppie-placeholder');
var $preview = $('.js-croppie-preview');
$preview.croppie({
viewport: { width: 240, height: 320 },
showZoomer: true,
enableOrientation: true,
enableExif: true // Fix iOS rotation issues
});
function readFile(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (event) {
$preview.croppie('bind', {
url: event.target.result
});
$croppie.addClass('has-image');
$placeholder.hide();
};
reader.readAsDataURL(input.files[0]);
} else {
alert('Sorry, your browser doesn\'t support the FileReader API.');
}
}
// Submit button click
$('.js-croppie-submit').on('click', function (e) {
e.preventDefault();
var $form = $(this.form);
$preview.croppie('result', {
type: 'base64',
size: 'viewport',
format: 'jpeg',
quality: 0.9
}).then(function (resp) {
$form.find('.js-croppie-hidden-field')
.val(resp)
.attr('value', resp);
$form.trigger('submit');
}).catch(function (err) {
console.log(err);
});
return false;
});
$('.js-croppie-rotate').on('click', function (ev) {
var rotateVal = parseInt($(this).data('deg'), 10);
$preview.croppie('rotate', rotateVal);
});
$('.js-croppie-field').on('change', function () {
var hasValue = $(this).val();
$('.js-croppie-submit').prop('disabled', !hasValue);
if (hasValue) {
readFile(this);
} else {
$croppie.removeClass('has-image');
$placeholder.show();
}
}).trigger('change');
$('.js-croppie-upload').on('click', function () {
$('.js-croppie-field').trigger('click');
});
$('.js-croppie-delete').on('click', function () {
$('.js-croppie-field').val('').trigger('change');
}); As you can see, I'm using Croppie to generate a base64 string which gets sent to the server using a hidden input field. It seems to be a browser related issue - it has been reported in Chrome on Windows 10 and also by some mobile users. The black rectangle makes me think that the base64 string might be cut off somewhere, could that be possible? |
@dduupp did you find a fix or workaround for this problem? |
Expected Behavior
Cropped image should be the same as in a viewport while editing
Actual Behavior
After rotation and moving viewport to the right bottom corner it crops too much and image gets filled with black pixels
Steps to Reproduce the Problem
*image height should be greater than width
Example Link
Codepen
Version 2.6.4
The text was updated successfully, but these errors were encountered: