Creating thumbnails of the images is required many a times, this code will be useful to know about the logic of thumbnail generation.