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

Can't use Base64 as source #7

Open
trainbolt opened this issue Jan 10, 2018 · 11 comments
Open

Can't use Base64 as source #7

trainbolt opened this issue Jan 10, 2018 · 11 comments

Comments

@trainbolt
Copy link

It would be really handy to be able to use base64 as the image instead of a URL... do you know of a way to do this?

This looks amazing and I'd really love to be able to use it.

Thanks.

@mimimimichael
Copy link

mimimimichael commented Feb 19, 2018

I kinda got it to work. jimp (the underlying image-processing libarary) can handle different inputs. With the function from this gist you can transform the base64 url into a Uint8Array and grab the buffer from there.

const base64File = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA...'
const readableFile = convertDataURIToBinary(base64Image).buffer;

<ProcessImage image={readableFile}/>

Unfortunately another script (browser-image-resize) is throwing an error but the image filters i used are applied correctly. Don't know if resizing will still work though.

Still, it would be nice to see this handled in a better way, since it's a quite common usecase. Image Upload -> Base64 -> do some transformation ... -> Send to server.

@nitin42
Copy link
Owner

nitin42 commented Feb 20, 2018

Yup! This totally makes sense. I will look into this issue this week. Sorry, I've been busy lately with some other projects and didn't notice @trainbolt suggestion.

@nitin42
Copy link
Owner

nitin42 commented Feb 20, 2018

Can you tell me exactly what sort of error occurs due to browser-image-resize ?

@nitin42
Copy link
Owner

nitin42 commented Feb 20, 2018

Also, it would be nice if you could share an example of how you are using the base64 images with jimp.

@nitin42
Copy link
Owner

nitin42 commented Mar 3, 2018

@alotov-agina I'd be open to a PR for this. I am busy with some other work. But I can help you with this work,

Thanks!

@mrjosshi
Copy link

is there any solution available for this?

@nitin42
Copy link
Owner

nitin42 commented Mar 28, 2018

You can use probe-image-size instead of browser-image-size to support base64.

@mrjosshi
Copy link

is it another dependency where i need to add this? could you please clear this in details or any example for this
TIA

@nitin42
Copy link
Owner

nitin42 commented Mar 29, 2018

Sorry, I've been busy lately. So, the error is being caused by the dependency "browser-image-size". To make it work (base64), you need to replace that dependency with "prob-image-size". That's it!

@yueHan98
Copy link

Sorry, I've been busy lately. So, the error is being caused by the dependency "browser-image-size". To make it work (base64), you need to replace that dependency with "prob-image-size". That's it!

Hi, I tried this solution, but then probe-image-size is throwing a weird error: "TypeError: merge is not a function" when I do have deepmerge installed. Is there a solution for that? Thanks!

@yueHan98
Copy link

It seems that I've fixed the TypeError which is caused by the deepmerge package the probe-image-size package is relying on. However, now the componentDidMount function in main.js is throwing a "options.uri is a required argument" error and I'm wondering if you could give me a hint on how to fix that. Thanks in advance. :)

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

5 participants