Cropper: Fill color to transparent background within cropbox.

Created on 20 Jan 2017  路  9Comments  路  Source: fengyuanchen/cropper

Hi, I want to crop all size image into square.

However, some of the images are rectangle so that I allow user to zoom in & out the image.

After that, I will get the cropped x, y, width, height from cropper("getData") and crop it at server side.

Is there any way to fill color into the transparent background?

For example:
image

The transparent area in the crop box will filled with white color.

Most helpful comment

$().cropper('getCroppedCanvas', { 
  fillColor: '#fff' 
})

All 9 comments

.cropper-crop-box {
  background-color: white;
}

The background will not append to the photo right?

After I set to white, but the cropped image doesn't include the background also, it shows as transparent..

$().cropper('getCroppedCanvas', { 
  fillColor: '#fff' 
})

how to do this in Angular 4+? @fengyuanchen

I am getting similar issue, when I upload a png cropper adds black background. Any idea how can i fix this in Angular 8 @fengyuanchen ?

I uploaded:

PNG_transparency_demonstration_1

And i got this after crop:

PNG_transparency_demonstration_1 (1)

I am getting similar issue, when I upload a png cropper adds black background. Any idea how can i fix this in Angular 8 @fengyuanchen ?

I uploaded:

PNG_transparency_demonstration_1

And i got this after crop:

PNG_transparency_demonstration_1 (1)

same issue with me

I am getting similar issue, when I upload a png cropper adds black background. Any idea how can i fix this in Angular 8 @fengyuanchen ?
I uploaded:
PNG_transparency_demonstration_1
And i got this after crop:
PNG_transparency_demonstration_1 (1)

same issue with me

This was quite simple. I did a mistake while specifying the format. Just mention it as png and the cropper wont add default background.

#imageCropper
[imageChangedEvent]="imageChangedEvent"
format="png"
outputType="file"
autoTriggerCrop="false"
autoCrop="false"
[aspectRatio]="aspectRatio"
[maintainAspectRatio]="true"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"

I am getting similar issue, when I upload a png cropper adds black background. Any idea how can i fix this in Angular 8 @fengyuanchen ?
I uploaded:
PNG_transparency_demonstration_1
And i got this after crop:
PNG_transparency_demonstration_1 (1)

same issue with me

This was quite simple. I did a mistake while specifying the format. Just mention it as png and the cropper wont add default background.

imageCropper

[imageChangedEvent]="imageChangedEvent"
format="png"
outputType="file"
autoTriggerCrop="false"
autoCrop="false"
[aspectRatio]="aspectRatio"
[maintainAspectRatio]="true"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"
>

Can we also specify format while adding cropper in javascript

I am getting similar issue, when I upload a png cropper adds black background. Any idea how can i fix this in Angular 8 @fengyuanchen ?
I uploaded:
PNG_transparency_demonstration_1
And i got this after crop:
PNG_transparency_demonstration_1 (1)

same issue with me

This was quite simple. I did a mistake while specifying the format. Just mention it as png and the cropper wont add default background.

imageCropper

[imageChangedEvent]="imageChangedEvent"
format="png"
outputType="file"
autoTriggerCrop="false"
autoCrop="false"
[aspectRatio]="aspectRatio"
[maintainAspectRatio]="true"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"
>

Can we also specify format while adding cropper in javascript

Sorry my question was related to cropperjs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThameDBA picture ThameDBA  路  4Comments

jzahka picture jzahka  路  4Comments

zilions picture zilions  路  3Comments

richdenis86 picture richdenis86  路  8Comments

WillJW picture WillJW  路  3Comments