fluttercandies / extended_image

A powerful official extension library of image, which support placeholder(loading)/ failed state, cache network, zoom pan image, photo view, slide out page, editor(crop,rotate,flip), paint custom etc.
https://fluttercandies.github.io/extended_image/
MIT License
1.91k stars 500 forks source link

Crop rectangle is rotated when the image is rotated. It should not rotate, only the image should be rotated. #277

Open anamauad opened 3 years ago

anamauad commented 3 years ago

Aspect is rotated when the image is rotated. It should not rotate, only the image should be rotated.

Steps to reproduce the problem:

  1. Select the image
  2. Set the aspect ratio to CropAspectRatios.ratio4_3
  3. Rotate to right

The image is rotated 90 degrees, but the crop rectangle is also rotated. It turns out to be CropAspectRatios.ratio3_4.

I think that it should not rotate the crop rectangle.

zmtzawqlp commented 3 years ago

as design

eriko13 commented 3 years ago

Why not add a parameter to switch between these two behaviors?

eriko13 commented 3 years ago

I have the same problem.

akadatsky commented 3 years ago

Faced with the same issue, solved it next way: Copied library as source code in my project and in the file extended_image_editor_utils.dart uncommented line: cropRect = rotateRect(cropRect, cropRect.center, -angle); in rotate() method (line 93).

Are there any other way to do it without editing library source code?

roosemberth commented 3 years ago

Encountered this issue today. Used the following workaround without modifying the lib: https://gitlab.com/roosemberth/Greenzz/-/commit/f1fce3509a1d86b05c717b8ec1a774cf4b80079a.

ramtinq commented 1 year ago

any update on this? after 2 years still the problem is left without any solution by the developers. I really like this package and prefer use the official one instead of my own modified version, but these problems need to be solved. Having a parameter for switching this behavior would be great.

zmtzawqlp commented 1 year ago
  1. This behavior as design. It's the same as many photo app on different smartphone.
  2. If crop rectangle is not follow with image, you can't make sure it's right to new image.
ramtinq commented 1 year ago

@zmtzawqlp I completely understand that, but how about the case when we want to provide some standard aspect ratios like most editing apps? In that case, rotating the crop rectangle would be opposed to its goal.

I have tried many approaches (without editing the package's source code) to create a workaround with no luck and weird stuff happening.

Strangely, this rotate function works, as provided in the package's example:

  void rotate(bool isToRight) async {
    editorKey.currentState?.rotate(right: isToRight);
  }

but this one, results in the cropRect to change, but the image will not rotate at all:

  void rotate(bool isToRight) async {
    editorKey.currentState?.rotate(right: isToRight);

    setState(() {
      if (_cropAspectRatio != null) {
        _cropAspectRatio = 1.0 / _cropAspectRatio!;
      }
    });
  }

I tried many many approaches, calling setState with delays, in different orders, ... but no luck. And force-rebuilding the entire ExtendedImage widget works but it will be flashy.

Isn't there any workaround to at least both rotate and change cropAspectRatio? why this strange behavior happens that the image does not rotate at all when changing cropAspectRatio?!

Eriickson commented 1 year ago

Has anyone found the solution to this?