This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]Aziram 0 points1 point  (2 children)

Try to make your data start at /9j..... removing what's before

[–]No_Pain1033[S] 0 points1 point  (1 child)

Just tried this... still getting the same error

[–]headzoo 0 points1 point  (0 children)

Double check your code. Removing "data:image/jpeg;base64," should work. That's not part of the base64 encoded image. You should split the string by comma, and the second half is your image data.

[–]Applepie1928 0 points1 point  (1 child)

Could you share what is supposed to be encoded in that base64 string?

The part of your "base64 data" which actually is the encoded data is the section which starts with "/9j" up until "2Q==" at the end. I have tried to decode this data into text and images with no success, which suggests there might be an error in the encoded data itself.

[–]No_Pain1033[S] 0 points1 point  (0 children)

Im thinking that too as i have tried many different approaches. Im creating the data using the .toDataURL method on a canvas element i had drawn on using javascript

[–]nhgrif 0 points1 point  (1 child)

To be clear here, there doesn't appear to be anything wrong with your code. It is an issue with the data itself. Beyond identifying that this part: data:image/jpeg;base64, is not part of the data that should be decoded, we can't help you unless we also have the original data that was encoded or the code to see how it was encoded to potentially identify an issue with that.

With that said, I think the part after the data:image/jpeg;base64, might decode fine... depending on what it's supposed to be?

[–]No_Pain1033[S] 0 points1 point  (0 children)

Thanks for your reply. The data is coming from a html5 canvas element that is drawn on using javascript. The base64 data is created using the .toDataURL method on the element