0

I have developped a brower plugin that Acquire a picture from a Scanner or a Camera and save the picture in the file system of the user. The output is the filepath to the picture. I want to preview the picture in the Broswer, using javascript...

How can I get the picture without user interaction ?

( part of a Web App only compatible with Google Chrome)

2 Answers 2

1

If you have the filepath returned by your browser plugin and you have identified the event when you have to display the image then you can call ShowImage(filepath) function on that event.

<script type="text/javascript">
    function ShowImage(filePath) {
        $("#preview").append("<img alt='img' src='" + filePath + "'");
    }
</script>

Your HTML should contain the div:

<div id="preview"></div>
Sign up to request clarification or add additional context in comments.

2 Comments

I tried the FileReader but it seems to be not working with an absolute path
One pre-requisite in this scenario is that you have to provide filepath as Absolute path not as Physical path
1

If you have the contents of the image already you can load them in directly, by base64 encoding it and providing an URL as follows:

<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />

3 Comments

Yes, but I'm working with HD Image, and base64 encoding give me a really too big string to manipulate.
@user2385830 You do not need to manipulate it, just insert in into the DOM. Are you certain this won't work?
I tried to return base64 string from my NPAPI plugin, and it crashes Chrome every time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.