Image manipulation


I need some help regarding image manipulation.
The input image is a simple random printed background (
The output required is a pleated version of it, one end of which is held closely (

Can you please suggest us some package/software which has such capabilities. Or do guide how this can be achieved.
I have been using Imagemagick till now. Please note that I need a script to do it.

Thanks in advance