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

using image restriction 'none' and aspect ratio. #265

Open
leonardo-melhor-envio opened this issue Jan 19, 2024 · 5 comments
Open

using image restriction 'none' and aspect ratio. #265

leonardo-melhor-envio opened this issue Jan 19, 2024 · 5 comments

Comments

@leonardo-melhor-envio
Copy link

leonardo-melhor-envio commented Jan 19, 2024

When adding these two properties to the "cropp" component, when generating the preview image, it does not align the source image to the center.

cropp component:
image


generated image:
image


implementation:

     <Cropper
        ref="cropper"
        :src="src"
        :stencil-props="{
          aspectRatio: 128/32,
          movable: true,
          resizable: true,
        }"
        :canvas="{
          maxWidth: 128,
          maxHeight: 32,
        }"
        image-restriction="none"
      />

Codesandbox

@Norserium
Copy link
Collaborator

@leonardo-melhor-envio, could you provide the codesandbox to reproduce your issue?

@leonardo-melhor-envio
Copy link
Author

@Norserium I updated the content of the issue, with the codesandbox link.

@romain-aragon
Copy link

I have the same problem. Seems that is related to coordinates and/or visibleArea and/or image.transform.translateX/Y not "zoomed" from original image and canvas representation.
image
With a small resolution image, that is near correct

But with a high resolution src image, when I crop with small left margin
image

The left position is huge...
image

@romain-aragon
Copy link

In the exemple, the left (-249.57) is related to the image width (4284) but is applied as is in the canvas width 640)
instead -249 * 640 / 4284 (or something like that)

@romain-aragon
Copy link

Have a look in canvas.ts
const offsetX = coordinates.left < 0 ? -coordinates.left : 0;

The coordinates.left is related to the source image, you have to transform in canvas relative coordinates

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

3 participants