YodaSpow / EmailDevTools

EmailTools
https://codepen.io/spowart/details/abWzBwR
7 stars 1 forks source link

Images: Check image sizes, show which ones are too big #43

Open YodaSpow opened 5 years ago

YodaSpow commented 5 years ago

Is your feature request related to a problem? Please describe. Would like to check if images are too big, not the width or height but the actual KB/MB.

Describe the solution you'd like Thinking any image which over 300KB would get flagged with a pop up.

Describe alternatives you've considered Lists all images in an email that is too large, preferably there would be a tooltip showing

Example from Litmus Rendercheck Sizes

YodaSpow commented 5 years ago

Post: http://voidcanvas.com/how-to-get-the-memory-size-byte-kb-mb-of-an-image-or-other-files-without-loading-it-by-javascriptajax/

<!DOCTYPE html>
<html>
    <head>
        <title>Get memory size of a file</title>
        <script type="text/javascript" src="main.js"></script>
    </head>

    <body onLoad="toGetSize()">

    </body>
</html>
function toGetSize() {

var obj = new XMLHttpRequest();
obj.open('HEAD', 'images/1.png', true);
obj.onreadystatechange = function(){
  if ( obj.readyState == 4 ) {
    if ( obj.status == 200 ) {
      alert('Size in bytes: ' + obj.getResponseHeader('Content-Length'));
    } else {
      alert('ERROR');
    }
  }
};
obj.send(null);

}
YodaSpow commented 5 years ago

https://www.codexworld.com/how-to/convert-file-size-bytes-kb-mb-gb-javascript/

https://www.webdeveloper.com/d/219516-how-to-get-file-size-and-file-name-of-an-image-in-domjavascript

YodaSpow commented 5 years ago

https://www.codexworld.com/how-to/convert-file-size-bytes-kb-mb-gb-javascript/

YodaSpow commented 5 years ago

Not fully related: https://stackoverflow.com/questions/934012/get-image-data-url-in-javascript/42916772#42916772 demo: canvas: http://jsfiddle.net/Parth_Raval/rqdw3s71/1/

YodaSpow commented 5 years ago

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch https://developer.mozilla.org/en-US/docs/Web/API/FileReader

YodaSpow commented 5 years ago

https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API demo: https://github.com/mdn/sw-test

YodaSpow commented 5 years ago

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Fetching_data