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.

How to set the initial cropper rectangular?

See original GitHub issue

Hi, first of all: Thanks for your excellent work!

Background: I’m using Angular 7 with face detection tool and would have available the proposed rectangular to crop from original image.

My issue: I’m sorry but I could not find out how to set the initial cropper rectangular coordinates. And yes, I tried cropper, but no success 😦

This did NOT work as intended: HTML: <image-cropper ... [cropper]="cropper"></image-cropper> JS: cropper:any = { x1: 0, y1: 0, x2: 200, y2: 300 };

Thank’s for any hints!

Similar to #52

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anantksinghcommented, Mar 1, 2019

HI, I am unable to set cropper position fix, it take full space <image-cropper [imageChangedEvent]=“imageChangedEvent” [maintainAspectRatio]=“true” [aspectRatio]=“1/1” [resizeToWidth]=“0” [onlyScaleDown]=“true” [roundCropper]=“false” format=“fileExtention” outputType=“both” (imageCropped)=“imageCropped($event)” (imageLoaded)=“imageLoaded()” (cropperReady)=“cropperReady()” (loadImageFailed)=“loadImageFailed()” [cropper] =“coordinates” [style.display]=“showCropper ? null : ‘none’”> </image-cropper>
Declare in two place
fileChangeEvent(event: any,templateUpload): void {
this.coordinates={x1: 161.5, y1: 34, x2: 360.5, y2: 233};
} imageLoaded() { this.showCropper = true; setTimeout(() => { this.coordinates={x1: 161.5, y1: 34, x2: 360.5, y2: 233}; console.log(‘Image loaded’,this.coordinates) }, 1000);

}
0reactions
NavjotKumarcommented, Mar 11, 2019

Cropper is not working

cropper = { x1: 0, y1: 0, x2: 410, y2: 546 };

i have added timeout also imageLoaded() { this.cropperReady = true; if (this.cropperReady === true) { setTimeout(() => { this.cropper = { x1: 0, y1: 0, x2: 410, y2: 546 }; }); console.log(this.cropper ); } }

this is html part

<image-cropper [imageChangedEvent]=“imageChangedEvent” [maintainAspectRatio]=“true” [aspectRatio]=“selectedRatio” format=“png” [imageQuality]=“85” [resizeToWidth]=“410” (imageLoaded)=“imageLoaded()” (loadImageFailed)=“loadImageFailed()” (imageCroppedBase64)=“imageCropped($event)” [style.display]=“cropperReady ? null : ‘none’”
outputType=“both” [cropper]=“cropper” [autoCrop]=false ></image-cropper>

Cropper is working fine in “ngx-image-cropper”: “0.1.21” i have tried your (@Mawi137 ) starblitz exaple https://stackblitz.com/edit/image-cropper-set-position

But not in “ngx-image-cropper”: “^1.3.8” https://stackblitz.com/edit/image-cropper

Both are your example only

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to crop by rectangular in angular 4 - Stack Overflow
I am using ng2-img-cropper for image crop but if the image is in rectangular shape then it does not capture the whole image, ......
Read more >
Crop a picture to fit in a shape - Microsoft Support
Next, use Crop > Fit or Crop > Fill to change how much of the picture fits ... fit within the shape while...
Read more >
Crop Image
Click and drag the crop tool handles (the black rectangles on the crop border, shown below) to change the dimensions of the selected...
Read more >
How to crop and straighten photos in Photoshop
Draw a new cropping area or drag the corner and edge handles to specify the crop boundaries in your photo. (Optional) Specify the...
Read more >
Crop image - MATLAB imcrop - MathWorks
You can move or resize the crop rectangle using the mouse. When you are finished sizing and positioning the crop rectangle, create the...
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