advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
930 stars 128 forks source link

Unexpected Background Blackening: Transparent Areas Rendered Black #245

Open Muhammad-Sarfaraz opened 10 months ago

Muhammad-Sarfaraz commented 10 months ago

Unforeseen Background Blackening: Complete Blackness Instead of Transparency After PNG Image Cropping.

Package:

"vue-advanced-cropper": "^2.8.6", 

image

Norserium commented 10 months ago

@Muhammad-Sarfaraz, do you use toDataURL or toBlob methods to get the cropped result? What mimeType do you use in this case?

Muhammad-Sarfaraz commented 10 months ago

@Muhammad-Sarfaraz, do you use toDataURL or toBlob methods to get the cropped result? What mimeType do you use in this case?

Mime : ".png"

Method: [toDataURL]

 this.$emit("update:modelValue", **result.canvas.toDataURL("image/jpeg"))**;
Norserium commented 10 months ago

That's the reason.

When you pass "image/jpeg" you won't preserve the transparency, you should pass "image/png" or nothing (because "image/png" is the default value).

Muhammad-Sarfaraz commented 9 months ago

That's the reason.

When you pass "image/jpeg" you won't preserve the transparency, you should pass "image/png" or nothing (because "image/png" is the default value).

Ok, That's mean on mime:.png I should use image/png. Will try this, in afternoon.

Norserium commented 9 months ago

@Muhammad-Sarfaraz, any news?

matthiasPOE commented 3 months ago

hi @Norserium currently hit the same issue.

Weirdly enough, i couldnt use the cropper preview due to responsive sizing issues so I just run my own <img :src="previewBase64" />

Which works fine and also shows as transparent. But as soon as I pass the previewBase64 string into the cropper tool I also get the black background even when I use image/png as suggested above.

Norserium commented 3 months ago

But as soon as I pass the previewBase64 string into the cropper tool I also get the black background even when I use image/png as suggested above.

Did you try to change the cropper's background to an another color?

matthiasPOE commented 2 months ago

wow codeblind + end of day is a bad combination haha. Thank you! Appreciated

Norserium commented 2 months ago

@matthiasPOE, you are welcome!