imagelib.cropImage.js 601 B

1234567891011121314151617181920
  1. /*
  2. Image Cropping Function
  3. This script demonstrate how to crop an image using imagelib
  4. Try to resize an image on desktop test.jpg to crop.jpg
  5. */
  6. if (requirelib("imagelib")){
  7. //if (imagelib.cropImage("ccns:/test.jpg", "user:/Desktop/ccns.jpg",100,100,200,200)){
  8. if (imagelib.cropImage("user:/Desktop/test.jpg", "user:/Desktop/out.jpg",100,100,200,200)){
  9. //Cropping suceed
  10. sendJSONResp(JSON.stringify("ok"))
  11. }else{
  12. sendJSONResp(JSON.stringify({
  13. error: "Unable to crop image"
  14. }))
  15. }
  16. }else{
  17. console.log("Image lib not found");
  18. }