question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong section cropped?

See original GitHub issue

Hi,

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:

2016-04-19 at 16-16-21

…and another example:

2016-04-19 at 16-19-57

The silly thing, is that it works fine with the exact same image:

2016-04-19 at 16-21-11

…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:closed
  • Created 7 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
thedustinsmithcommented, Apr 19, 2016

You could do

.cr-boundary img { max-height: none; max-width: none; }

Usually that css is in there for mobile images. We haven’t found a work around for croppie yet.

0reactions
erperejildocommented, May 24, 2016

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found