Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html>
<title>Image to Webp</title>

<head>
	<script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
	</script>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description"
		content="Jpeg To Webp Converter, Jpeg To Webp Converter Tool, Convert Jpeg To Webp, Compress Webp, Jpg To Webp Python, Jpg To Url, Webp Converter Download Free Convert Jpeg To Webp" />
	<meta name="robots" content="index,follow" />
	<meta name="keywords"
		content="Jpeg To Webp Converter, Jpeg To Webp Converter Tool, Convert Jpeg To Webp, Compress Webp, Jpg To Webp Python, Jpg To Url, Webp Converter Download Free Convert Jpeg To Webp" />
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<link href='https://techly360.com/image-to-webp-converter-tool-script-for-blogger/' rel='canonical' />
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
	<link rel="icon"
		href="https://1.bp.blogspot.com/-2f9VNsCCepY/X4U8S9ChkWI/AAAAAAAAF5Q/JE4CnBdLbx8vmBOCPKuSYLWheBM4lztcQCLcBGAsYHQ/s16000/ice_screenshot_20201013-110343.png"
		sizes="16x16" type="image/png">

	<style>
		body {
			width: 700px;
			margin: 0 auto;
			padding: 20px;
			font-family: sans-serif;
		}

		h1 {
			margin-top: 0;
		}

		input[type=file] {
			margin: 20px 0;
			margin-left: 200px;
		}

		img {
			max-height: 100%;
			max-width: 100%;
			box-shadow: 0px 0px 25px 0px rgba(0, 0, 0, 0.75);
		}

		.dropTarget {
			position: relative;
			border: 3px dashed silver;
			flex-basis: auto;
			flex-grow: 20;
		}

		.dropTarget::before {
			content: 'Drop files here';
			color: silver;
			font-size: 5vh;
			height: 5vh;
			position: absolute;
			top: 0;
			bottom: 0;
			left: 0;
			right: 0;
			margin: auto;
			text-align: center;
			pointer-events: none;
			user-select: none;
		}

		#previews>div {
			box-sizing: border-box;
			height: 240px;
			width: 240px;
			padding: 20px;
			display: inline-flex;
			justify-content: center;
			align-items: center;
			vertical-align: top;
		}

		#previews>div>progress {
			width: 80%;
		}

		.layout {
			display: flex;
			flex-direction: column;
			justify-content: flex-start;
			align-items: stretch;
			align-content: stretch;
			height: calc(100vh - 40px);
			margin: 2% auto;
			padding: 15px;
			background-color: #FFFFFF;
			-webkit-box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.2);
			box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.2);
		}

		.ads {
			margin: auto;
			padding: 60px 0;
			max-width: 640px;
			box-shadow: 0 5px 15px rgba(0, 0, 0, .16);
			border-radius: 5px;
			margin-top: 1em;
			background: #fff;
			text-align: left;
		}
	</style>
	<link rel="me" href="https://www.blogger.com/profile/08394030777419825740" />

	<!-- data-ad-client=ca-pub-9666432192120205 -->
</head>

<body style="background-image: linear-gradient(to right, #ff00ff);">
	<div class="container">
		<div class="layout">
			<center>
				<h1 style="text-align: center;">
					<span style="font-size: x-large;">🚀&nbsp;<span style="background-color: #2b00fe; font-family: Archivo Black;"> <span style="color: white;">Image to WebP Convert</span>&nbsp;</span>&nbsp;🚀</span>
				</h1>
			</center>
			<div>
				<div class="ads container">
					<center>
						<b><span style="font-size: x-large;"><span style="color: #2b00fe; font-family: Merriweather;">Serve images in next-gen Formats</span><span style="color: red;"> </span>⚡⚡⚡</span></b>
					</center>
				</div>
				<input type="file" multiple accept="image/*">
  </div>
				<div id="previews"></div>
				<div class="dropTarget"></div>
			</div>
		</div>
	</div>
	<br>

</body>
	<script>
		let refs = {};
refs.imagePreviews = document.querySelector('#previews');
refs.fileSelector = document.querySelector('input[type=file]');

function addImageBox(container) {
  let imageBox = document.createElement("div");
  let progressBox = document.createElement("progress");
  imageBox.appendChild(progressBox);
  container.appendChild(imageBox);
  
  return imageBox;
}

function processFile(file) {
  if (!file) {
    return;
  }
  console.log(file);

  let imageBox = addImageBox(refs.imagePreviews);

  // Load the data into an image
  new Promise(function (resolve, reject) {
    let rawImage = new Image();

    rawImage.addEventListener("load", function () {
      resolve(rawImage);
    });

    rawImage.src = URL.createObjectURL(file);
  })
  .then(function (rawImage) {
    // Convert image to webp ObjectURL via a canvas blob
    return new Promise(function (resolve, reject) {
      let canvas = document.createElement('canvas');
      let ctx = canvas.getContext("2d");

      canvas.width = rawImage.width;
      canvas.height = rawImage.height;
      ctx.drawImage(rawImage, 0, 0);

      canvas.toBlob(function (blob) {
        resolve(URL.createObjectURL(blob));
      }, "image/webp");
    });
  })
  .then(function (imageURL) {
    // Load image for display on the page
    return new Promise(function (resolve, reject) {
      let scaledImg = new Image();

      scaledImg.addEventListener("load", function () {
        resolve({imageURL, scaledImg});
      });

      scaledImg.setAttribute("src", imageURL);
    });
  })
  .then(function (data) {
    // Inject into the DOM
    let imageLink = document.createElement("a");

    imageLink.setAttribute("href", data.imageURL);
    imageLink.setAttribute('download', `${file.name}.webp`);
    imageLink.appendChild(data.scaledImg);

    imageBox.innerHTML = "";
    imageBox.appendChild(imageLink);
  });
}

function processFiles(files) {
  for (let file of files) {
    processFile(file);
  }
}

function fileSelectorChanged() {
  processFiles(refs.fileSelector.files);
  refs.fileSelector.value = "";
}

refs.fileSelector.addEventListener("change", fileSelectorChanged);

// Set up Drag and Drop
function dragenter(e) {
  e.stopPropagation();
  e.preventDefault();
}

function dragover(e) {
  e.stopPropagation();
  e.preventDefault();
}

function drop(callback, e) {
  e.stopPropagation();
  e.preventDefault();
  callback(e.dataTransfer.files);
}

function setDragDrop(area, callback) {
  area.addEventListener("dragenter", dragenter, false);
  area.addEventListener("dragover", dragover, false);
  area.addEventListener("drop", function (e) { drop(callback, e); }, false);
}
setDragDrop(document.documentElement, processFiles);
	</script>

	<body>
		<amp-auto-ads type="adsense" data-ad-client="ca-pub-9666432192120205">
		</amp-auto-ads>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console