vue-advanced-cropper icon indicating copy to clipboard operation
vue-advanced-cropper copied to clipboard

Unexpected Background Blackening: Transparent Areas Rendered Black

Open Muhammad-Sarfaraz opened this issue 2 years ago • 9 comments

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

Package:

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

image

Muhammad-Sarfaraz avatar Aug 20 '23 10:08 Muhammad-Sarfaraz

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

Norserium avatar Sep 04 '23 08:09 Norserium

@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"))**;

Muhammad-Sarfaraz avatar Sep 04 '23 08:09 Muhammad-Sarfaraz

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).

Norserium avatar Sep 04 '23 08:09 Norserium

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.

Muhammad-Sarfaraz avatar Sep 12 '23 05:09 Muhammad-Sarfaraz

@Muhammad-Sarfaraz, any news?

Norserium avatar Sep 29 '23 21:09 Norserium

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.

matthiasPOE avatar Apr 04 '24 14:04 matthiasPOE

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?

Norserium avatar Apr 04 '24 19:04 Norserium

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

matthiasPOE avatar Apr 05 '24 06:04 matthiasPOE

@matthiasPOE, you are welcome!

Norserium avatar Apr 05 '24 07:04 Norserium