imagelib.imageResize.js 625 B

123456789101112131415161718192021222324
  1. console.log("Image Resizing Test");
  2. //To test this, put a test.jpg on your desktop
  3. var srcPath = "user:/Desktop/test.jpg";
  4. var destPath = "user:/Desktop/output.jpg";
  5. //Check if the file exists
  6. requirelib("filelib");
  7. if (!filelib.fileExists(srcPath)){
  8. sendResp("File not exists!")
  9. }else{
  10. //Require the image library
  11. var loaded = requirelib("imagelib");
  12. if (loaded) {
  13. //Library loaded. Call to the functions
  14. var success = imagelib.resizeImage(srcPath, destPath, 200, 0);
  15. if (success){
  16. sendResp("OK")
  17. }else{
  18. sendResp("Failed to resize image");
  19. }
  20. } else {
  21. console.log("Failed to load lib: imagelib");
  22. }
  23. }