i'm using the API JIMI (Java Image Mangement Interface) and i would like to convert any image like gif, jpg, bmp,... to an image *.ico,i have used this first part of source code in my program

Image img=Jimi.getImage("a.jpg");

but i have got this Exception "Cannot find encoder for a.ico" when i executed my program, after that i have tried to use an other possible source code which is

String str="a.jpg";
String s="a.ico";
Image img=Jimi.getImage(str);
File f=new File(s);
FileOutputStream out = new FileOutputStream(f);
ICOEncoder ico = new ICOEncoder();
JimiReader jir=Jimi.createJimiReader(str);

but i have faced the exception exception of image/x-icone exception it require the palette image

i was wondering if someone would mind helping me to solve this problem or giving me any suggestion for help.