i m having a page in which users upload their images to convert into black and white image..

i tried some of the code from internet but it works only for jpeg image when i upload some gif 

or png images it shows an full black image or the same image with the same color scale...

any codes appreciated.