Skip to content
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

Cropping when rotating #293

Open
chilipote opened this issue Mar 13, 2017 · 23 comments
Open

Cropping when rotating #293

chilipote opened this issue Mar 13, 2017 · 23 comments

Comments

@chilipote
Copy link

Hi,

I would like to know, if it's a bug or something I did wrong : I added today the enableOrientation: true option. Working great, the image is rotating. Yay. But I have some troubles during cropping.

In some words : I'm having an image larger than higher. When I flip it to the right, the image become higher than larger. If I try to crop the bottom of the image, the result can be transparent. And because images are always better than words :

Here the image I want to upload :
croppie_1

Then I flip it
croppie_2

I select the bottom of the image
croppie_3

And here the result
croppie_4

Am I the only one who experienced that ? Let me know if it's not clear.

Last version of Croppie : 2.4.1
Google chrome
Original dimension of the image : 1000 * 667
Viewport : 200 * 200
Boundary : 260 * 260

@chilipote
Copy link
Author

I think, maybe I found the problem :

croppie.js, _getCanvas, line 993.

    if (right > self._originalImageWidth) {
      width = self._originalImageWidth - left;
      outWidth = width;
    }
    if (bottom > self._originalImageHeight) {
      height = self._originalImageHeight - top;
      outHeight = height;
    }

I think this check, right > self._originalImageWidth is wrong in rotate situation, what do you think ?

@INJumbo
Copy link

INJumbo commented Mar 26, 2017

I am having this issue too, commented those if statements and issue has gone :)
Thanks !

@INJumbo
Copy link

INJumbo commented Mar 26, 2017

In my case those lines was like this

if ((left + width) > self._originalImageWidth) {
width = self._originalImageWidth - left;
outWidth = width;
}
if ((top + height) > self._originalImageHeight) {
height = self._originalImageHeight - top;
outHeight = height;
}

@chilipote
Copy link
Author

chilipote commented Apr 3, 2017

@INJumbo which version did you have ?

@raykudo
Copy link

raykudo commented May 20, 2017

+1

@jlozanoher
Copy link

Same issue for me, when rotating and moving vertically.

@thedustinsmith
Copy link
Contributor

#326 was believed to has resolved this issue, but it seems some people are still having it. I can't get it to happen myself.

I've used the rotation example on demo page, rotated, dragged to the bottom, and the resulting image seems to be correct. I've not made a release since 326 was merged in, so I'm just using the code in master to do so. Can anyone pull the latest code from master and confirm that this issue is a thing of the past?

@antoinelorcy
Copy link

I think this is fixed. I don't reproduce anymore using the latest 2.5.0

@JonathonRichardson
Copy link

JonathonRichardson commented Oct 19, 2017

I can still reproduce this with both master and the 2.5.0. It only happens with enforceBoundary disabled and an image with an aspect ratio of something other than 1:1. It looks to me like the problem is that the original image's width and height are used during the final drawing calculation. If the image was rotated an odd multiple of 90 degrees, that means it is using the width as the height and vice versa. I'm able to fix this so far (I haven't tested it extensively yet) by adding the following to the end of the _rotate() function to swap the original values:

if ((deg % 180) !== 0) {
    var lastOriginalHeight = this._originalImageHeight;
    this._originalImageHeight = this._originalImageWidth;
    this._originalImageWidth = lastOriginalHeight;
}

@thedustinsmith, does that seem like the right way to fix this?

@Hesesses
Copy link

having the same problem as above

@rickthewebdev
Copy link

@JonathonRichardson solucion fixed it for me. Thank you 👍

@hikari82
Copy link

Thanks to @JonathonRichardson.. it fixed for me to.

@thedustinsmith
Copy link
Contributor

Thanks for all the feedback in this one guys. I believe this issue is fixed in 2.5.2. I can't recreate the issue using the rotate example in the demo page. 2.5.2 should be released soon.

@thedustinsmith
Copy link
Contributor

@bhavikvaishnani Can you provide a video demonstrating the issues, or steps to recreate the issue?

@mishavee
Copy link

For me the problem showed in Croppie v2.4.1. Playing with jsbin, v2.4.0 has the problem, earlier versions don't work with my example, and the problem no longer shows from v2.5.1.

Example link:
http://jsbin.com/hulowasusi/edit

Steps:

  1. Rotate right.
  2. Drag dog all the way up so the eye is at the crop edge.
  3. Press result.
  4. Scroll down to see if the cropped image has a white area on the bottom.

@ghost
Copy link

ghost commented Mar 2, 2019

yup @mishavee the cropped dog does have a white area :( 👍 has this issue been solved ?

@pbf79
Copy link

pbf79 commented Mar 27, 2019

@rohitPagal it seems like a regression (in 2.6.4).
If i use https://raw.githubusercontent.com/Foliotek/Croppie/pre-2.5.2/croppie.min.js it works.

@mrhaver
Copy link

mrhaver commented Jun 4, 2019

@mishavee thanks for your jsbin 👍

Bug still seems to occur in 2.6.3 and 2.6.4 unfortunately just for your information.

In 2.6.2 this bug is fixed, but i can't use this version in my code.

@thedustinsmith thedustinsmith reopened this Jun 4, 2019
@mjunaid720
Copy link

it works fine on 2.4.1 at least

@vadymstebakov
Copy link

@mrhaver Have you decided this problem in 2.6.4?

@vadymstebakov
Copy link

@thedustinsmith Bug still occur in 2.6.4. When I rotate in the bottom of the image. Here is a link: https://codepen.io/by_olegovichs/pen/LYVMNaY?editors=0010

@tristanbenier
Copy link

Hi guys.
I am facing the same issue with 2.6.4.

#711 fixed the issue for me.

@martinduris
Copy link

It is possible to expect fix (i have seen PR which should fix it) ? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests