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

Unexpected Background Blackening: Transparent Areas Rendered Black #245

Open
Muhammad-Sarfaraz opened this issue Aug 20, 2023 · 9 comments

Comments

@Muhammad-Sarfaraz
Copy link

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

Package:

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

image

@Norserium
Copy link
Collaborator

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

@Muhammad-Sarfaraz
Copy link
Author

@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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

@Muhammad-Sarfaraz, any news?

@matthiasPOE
Copy link

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
Copy link
Collaborator

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
Copy link

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

@Norserium
Copy link
Collaborator

@matthiasPOE, you are welcome!

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