Classifying image by file extension within a PDF creator
Naturally, you can use a dictionary to map extensions to file types:


"jpg" -> ImageFileType.Jpeg
"jpeg" -> ImageFileType.Jpeg
"bmp" -> ImageFileType.Bmp
"gif" -> ImageFileType.Gif
... and so on


If the key fileExtension exists in the dictionary, you set sourceImage.ImageInfo.ImageFileType to the mapped file type, otherwise simply do nothing.
That will get rid of all the if-else.