imagelib.loadThumbString.js 614 B

12345678910111213141516171819
  1. /*
  2. Image Thumbnail Loading
  3. This script demonstrate the methods to load a thumbnail as base64 string given
  4. its virtual filepath
  5. */
  6. if (requirelib("imagelib")){
  7. var thumbImageBase64 = imagelib.loadThumbString("user:/Desktop/test.jpg");
  8. if (thumbImageBase64 != false){
  9. //Set the respond header to image
  10. HTTP_HEADER = "text/html"
  11. sendResp('<img src="data:image/jpg;base64,' + thumbImageBase64 + '"></img>');
  12. }else{
  13. sendResp('Failed to load thumbnail for this resource (You sure the format is supported?)')
  14. }
  15. }else{
  16. console.log("Image lib not found");
  17. }