imagelib.cropImage.js 510 B

12345678910111213141516171819
  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("user:/Desktop/test.jpg", "user:/Desktop/out.jpg",100,100,200,200)){
  8. //Cropping suceed
  9. sendJSONResp(JSON.stringify("ok"))
  10. }else{
  11. sendJSONResp(JSON.stringify({
  12. error: "Unable to crop image"
  13. }))
  14. }
  15. }else{
  16. console.log("Image lib not found");
  17. }