In the previous post i have mentioned about integrating the Jcrop functionality with ImageMagick to hide the selected coordinates of the image using a specific color.But here i am describing on the core feature of Jcrop i.e cropping the image in runtime with the selected coordinates.Here also , we are using ImageMagick in server side to accomplish the whole process.
You all know that Jcrop is a powerful image cropping engine for jQuery. It’s been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing their time ,flexibility and performance.
ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of fomats (over 100) like DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. We can use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick have a power full command line tool known as “Convert”. Convert has around 265 options for manipulating images .
So now we are going to integrate this two with Rails ,i wont go in depth of how to create the whole process.
In summery :
- User choose an image and uploads to a server using paperclip.
- Wep app shows the images to user and allows him/her to select the desired piece of selection of the image to hide using Jcrop.
- Using an Ajax post request ,we are sending the parameters (X-cord,Y-cord,Height,Width) to the sever which responsible to crop the portion of the image.
- The appropriate action in the controller will accept the parameters,and then crop the parameters by using a piece of Image-magic code.