Thursday, 21 May 2015

Image Croping Tool with JS and JQuery in VF page.

Hi Guys,


In this post i am going to show how we can crop an image and upload it in Documents Object of Salesforce.

I am taking a simple example and following the below mentioned steps:-
  • Create a VF page which has a upload image link.
  • on click of upload link i am opening a pop up of another VF page which is used to select image file from local system.
  • now after selecting file click on upload button.
  • after clicking on upload button magic is started now you can zoom-in, zoom-out or drag image and can easily select part of image you needed to upload in salesforce document.
  • Finally on click of save button image is inserted in document object and pop up window is closed.
Here the code:-

Screen Shoots:-
Upload Picture Page

On click of upload link opened popup page

choose picture from local system

selected picture get uploaded

Zoom Out picture

Zoom In Picture

Finally crop Picture

cropped picture saved


Hope this helps...happy Coding

Thanks
Anurag Jain

6 comments:

  1. I am not able to get the picture when i am click the OK button on popup dialog box. I am using overall code but finally image does not display in that box. please give me suggestion

    ReplyDelete
    Replies
    1. Did you get any other solution for this mani :)

      Delete
  2. Hello Anurag,

    Crop function is not working , can you help with this.

    Thanks

    ReplyDelete
  3. can you share or mail me your code because this is a working code.

    ReplyDelete
    Replies
    1. Hey Anurag,

      My bad... code is working fine. I have some different requirement very similar to this will get back to you.

      Thanks

      Delete
  4. Hi Anurag Jain.
    Thanks for greate work. Have you written a Test Class for the Image Cropper?
    Best regards
    Soren Klint

    ReplyDelete