Code to convert any image format

The following code converts any image format,

public void ConvertImage2Jpeg(string input, string output)
{
try
{
ImageCodecInfo myimagecodeinfo;
string inputpath;
string outputpath = output;
string format;
inputpath = input;
format = inputpath.Substring(inputpath.LastIndexOf(".") + 1);

if (format == "tif")
{
myimagecodeinfo = GetEncoderInfo("image/tiff");

}
else
{
myimagecodeinfo = GetEncoderInfo("image/" + format);

}
EncoderParameters eparam = new EncoderParameters(1);
EncoderParameter encparam;
System.Drawing.Imaging.Encoder enc;
enc = System.Drawing.Imaging.Encoder.Transformation;
encparam = new EncoderParameter(enc, (long)EncoderValue.TransformRotate90);
eparam.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 10L);
string jpg;
Image img;
img = Image.FromFile(inputpath);
jpg = outputpath.Substring(0, outputpath.LastIndexOf("\\") + 1) + Path.GetFileNameWithoutExtension(inputpath) + ".JPG";
img.Save(jpg, myimagecodeinfo, eparam);

}
catch (Exception exp)
{

}

}

private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}