import imghdr
image_path = 画像ファイルへのパス
image_type = imghdr.what(image_path)
if image_type is None:
	print('画像ではありません。')
else:
	print(str(image_type)+'画像です。')