Home » Convert base64 to image VUEJS

Convert base64 to image VUEJS

Today, We want to share with you Convert base64 to image VUEJS.In this post we will show you generate base 64 image to file type/object, hear for Vue trying to get base64 images we will give you demo and example for implement.In this post, we will learn about Converting images to a Base64 data URL with an example.

Convert base64 to image VUEJS

There are the Following The simple About Decode of Base 64 API using vuejs Full Information With Example and source code.

As I will cover this Post with live Working example to develop generate image to base64 in react, so the some major files and Directory structures for this example is following below.

Read Also:  Vue.js Hello World

Vue.js – The simple Easy to Use Progressive JavaScript Framework.Vue.js is an free Based to open-source js Model–view–controller JavaScript framework for building user friendly interfaces and single-page super web applications. as well as you step by step simple vuejs based insert update delete or select On vue.It can be used to create applications such as CRMs and CMSs based on CRUD (create, read update, as well as delete). The Vue js CRUD.

Keywords: How to generate url image into base64 using Vue,vue src base64,create base64 image VUEJS,base64 to-image – npm,image src base64 VUEJS,generate image to base64 jquery,generate image url to base64 VUEJS without canvas,congenerate vert image to base64 VUEJS,generate image url to base64 angular 6,VUEJS generate image to base64,generate image to base64 es6,generate image to base64 in react,vue image base64,Decode of Base 64 API using vuejs,generate base 64 image to file type/object,Vue trying to get base64 images,Converting images to a Base64 data URL.

Read Also:  Axios Post Request in vue.js

Step 1: HTML Code

Convert image to base64 using VueJS?

<script src="https://unpkg.com/vue"></script><divid="content-data">
  <p>
   <input @change="uploadImage" type="file" name="photo" accept="image/*">
  </p>
  <img :src="imageSrc" class="image">  
</div>

Step 2: Vuejs Code

javascript file

Vue.config.debug = false;
Vue.config.devtools = false;
Vue.config.silent = true;

var vm = new Vue({
  el: '#content-data',
  data: {
    imageSrc: null
  },
  methods: {
    uploadImage: function() {    
      var file = document
        .querySelector('input[type=file]')
        .files[0];
      var reader = new FileReader();
      reader.onload = function(e) {
        vm.imageSrc = e.target.result             
      };
      reader.onerror = function(error) {
        alert(error);
      };
      reader.readAsDataURL(file);      
    }
  }
});

Example 2:How to convert url image into base64 using Vue

generate Image to base64 from url using canvas and vuejs

Read Also:  VueJS Routing and Templating example

Source Code

<script>
   let profile = ''
   export default{
      created(){
          this.productsData('urlDaImagem', (dataUri) => {
              profile = dataUri
          })
      },
      methods: {
          productsData(url, callback){
              let profile = new Image()

              profile.onload = () => {
                  let ex_data = document.createElement('canvas');
                  ex_data.width = this.naturalWidth
                  ex_data.height = this.naturalHeight
                  ex_data.getContext('2d').drawImage(this, 0, 0)
                  callback(ex_data.toDataUrl('image/png').replace(/^data:image\/(png|jpg);base64,/, ''))
                  callback(ex_data.toDataURL('image/png'))
              }

              profile.src = url
          }
      }
   }

</script>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about generate image url to base64 VUEJS without canvas.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  vuejs Scroll smoothly to specific element on page
  2. Read Also:  Vuejs json Custom Filter example
  3. Read Also:  Accessing Complex Nested JSON objects in VueJs
  4. Read Also:  Retrieve Multiple Checkbox Selected Options using VueJS
  5. Read Also:  Laravel 6 Allow CORS All requests Middleware Tutorial
  6. Read Also:  How to Open URL in New Tab using Vue JS
  7. Read Also:  How to get image in vuejs?
  8. Read Also:  Retrieve Multiple Checkbox Selected Options using VueJS
  9. Read Also:  Axios Post Request in vue.js
  10. Read Also:  vuejs Scroll smoothly to specific element on page

Leave a Comment

Your email address will not be published. Required fields are marked *