Wrong section cropped?
See original GitHub issueHi,
I’ve got a bit of a weird issue here!
Below is my JS:
var $uploadCrop;
$(document).ready( function() {
$uploadCrop = $('#uploader-avatar').croppie({
// enableExif: true,
viewport: {
width: 200,
height: 200,
type: 'square'
},
boundary: {
width: 300,
height: 300
}
});
$uploadCrop.bind();
$('#upload').on('click', function () {
$('#view-avatar').hide();
if (typeof $uploadCrop != "object") {
}
});
$('#upload').on('change', function () { readFile(this); });
$('.upload-result-avatar').on('click', function (ev) {
$uploadCrop.croppie(
'result', {
type: 'canvas',
size: 'viewport',
format: 'jpeg'
}).then(function (resp) {
console.log(resp);
$('#view-avatar').show();
$('#currentAvatar').show().attr('src',resp);
});
});
});
function readFile(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$uploadCrop.croppie('bind', {
url: e.target.result
});
console.log("show it")
$('.upload-result-avatar').show();
}
reader.readAsDataURL(input.files[0]);
}
else {
alert("Sorry - you're browser doesn't support the FileReader API");
}
}
…and the HTML:
<div id="upload-avatar" style="background:green">Upload Avatar:</div>
<div id="avatar-upload-wrapper">
<div id="view-avatar">
<img id="currentAvatar" src="<%if user.avatar_image%><%avatar_image%><%else%>/images/no-profile-image.png<%endif%>" />
</div>
<div class="actions" id="uploader-avatar">
<a class="btn file-btn">
<span>Upload</span>
<input type="file" id="upload" value="Choose a file" accept="image/*" />
</a>
<button class="upload-result-avatar">Save Avatar</button>
</div>
</div>
However, when I run that - I get a weird crop (totally wrong size, and even the wrong place. Here are a couple of screenshots:
…and another example:
The silly thing, is that it works fine with the exact same image:
…you can give it a whirl here:
http://andyapp.com.nmsrv.com/test/test.html
Any ideas? I’m drawing a blank 😕
Cheers
Andy
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Jcrop Cropping images does not work properly, wrong ...
I had the same issue. One probable cause is that the coordinates are changed due to the image resizing (explicitly or implicitly) at...
Read more >Troubleshooting cropping issues - Squarespace Help Center
If your section background image or video appears cropped, change the section height or width to show more of your image or video....
Read more >Cropped View Error on Sheet - Revit Products
I have unit plans with complex crop regions. When I place them on sheet, model elements (except rooms and room bounding lines) disappear....
Read more >Preview App Printing a Cropped PDF Incorrectly
After cropping a PDF file, the Preview app shows the cropped area only. So far, so good. But if I print the document,...
Read more >How to crop and straighten photos in Photoshop
Crop borders display on the edges of the photo. Draw a new cropping area or drag the corner and edge handles to specify...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could do
Usually that css is in there for mobile images. We haven’t found a work around for croppie yet.
No, I didn’t, just that tag on my html and in the script file the initialize. All empty.
Am I the only one with that problem?