example1.html 849 B

123456789101112131415161718192021222324
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Jimp browser example 1</title>
  5. </head>
  6. <body>
  7. <h1> Demonstrates loading a local file using Jimp on the main thread </h1>
  8. <script src="../lib/jimp.min.js"></script>
  9. <script>
  10. Jimp.read("https://upload.wikimedia.org/wikipedia/commons/0/01/Bot-Test.jpg").then(function (lenna) {
  11. lenna.resize(256, Jimp.AUTO) // resize
  12. .quality(60) // set JPEG quality
  13. .greyscale() // set greyscale
  14. .getBase64(Jimp.AUTO, function (err, src) {
  15. var img = document.createElement("img");
  16. img.setAttribute("src", src);
  17. document.body.appendChild(img);
  18. });
  19. });
  20. </script>
  21. </body>
  22. </html>