Skip to main content

Free online tool to convert jpg, png, gif, ico to webp image format online.

Free online tool to convert jpg, png, gif, ico to webp image format online. No upload, just select image in tool and click convert to webp button. Once converted, download button is enabled to download webp image.

Here is a sample HTML, CSS, and JavaScript code that you can use to create a simple online tool to convert JPG, PNG, GIF, and ICO images to the WebP format: 

<!-- HTML -->
<html>
  <head>
    <title>Image Converter</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <h1>Image Converter</h1>
    <input type="file" id="input-file" accept=".jpg,.png,.gif,.ico">
    <button id="convert-button">Convert to WebP</button>
    <a id="download-link" download="converted.webp">Download</a>
    <script src="script.js"></script>
  </body>
</html>

/* CSS */
#input-file {
  display: none;
}

#convert-button {
  display: inline-block;
  padding: 0.5em 1em;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#download-link {
  display: none;
  font-size: 1.2em;
  background-color: #00bcd4;
  color: white;
  padding: 0.5em 1em;
  border-radius: 4px;
  text-decoration: none;
}

// JavaScript
function convertToWebp(file, callback) {
  var reader = new FileReader();
  reader.onload = function() {
    var image = new Image();
    image.onload = function() {
      var canvas = document.createElement('canvas');
      canvas.width = image.naturalWidth;
      canvas.height = image.naturalHeight;
      canvas.getContext('2d').drawImage(image, 0, 0);

      var webpData = canvas.toDataURL('image/webp');
      callback(webpData);
    };
    image.src = reader.result;
  };
  reader.readAsDataURL(file);
}

document.querySelector('#input-file').addEventListener('change', function() {
  var file = this.files[0];
  convertToWebp(file, function(webpData) {
    document.querySelector('#download-link').href = webpData;
    document.querySelector('#download-link').style.display = 'inline-block';
  });
});

document.querySelector('#convert-button').addEventListener('click', function() {
  document.querySelector('#input-file').click();
});

This code creates a file input field that allows the user to select an image file, a "Convert" button that initiates the conversion process, and a "Download" link that is displayed once the conversion is complete. The JavaScript code uses the FileReader API to read the selected file, creates an image element and draws the image onto a canvas, and then uses the canvas.toDataURL() method to convert the image data to the WebP format

Comments

Popular posts from this blog

C++ Programming Tutorial - How to Install Code::Blocks in Ubuntu Linux - Learn Online

Installing Code::Blocks How do I Install Code::Blocks HOWTO: Installing Code::Blocks 10.05 How do you install Irrlicht on Code::Blocks? How do you install CodeBlock on ubuntu? codeblocks /bin/sh: g++: not found Installing codeblocks on ubuntu Installing Code::Blocks on Ubuntu 10.04?

How To Install Kali Linux in VirtualBox - Learn Online

in this video I am going to sho you How to install Kali Linux in Virtualbox : Step-by-step . This is A detailed guide on installing Kali Linux on VirtualBox. I am going to show How to Install Kali Linux 2016 + Guest Additions on VirtualBox. Install Kali linux 2.0 on Virtual Box Step by Step Install Kali LInux 2 in VirtualBox Installing Kali Linux 2016.1 on VirtualBox

How to install Skype on Ubuntu Linux 13.04/12.10/12.04 x64/x32 bit - Learn Online

Required commands to install skype sudo dpkg --add-architecture i386 sudo apt-get update sudo add-apt-repository "deb $(lsb_release -sc) partner" sudo apt-get update && sudo apt-get install skype Download Skype for Linux, get Skype for Linux How to Install Skype Using Terminal on Ubuntu How to install Skype with 13.04 How do I install Skype Install Skype on Ubuntu 12.04 LTS 64-bit How to install Skype in Ubuntu 13.04 How to get Skype for Ubuntu How to install skype in ubuntu 12.04 Latest Skype Release Added to Ubuntu Software Center How do I add Skype to my version of Ubuntu Skype for Ubuntu (32-bit) How to get Skype video call to work in Ubuntu How to Get Rid of Skype on Ubuntu How to Install Skype Wrapper and Integrate Skype into Ubuntu