from PIL import Image
import io


def strip_exif_data(content, content_type):
	""" Strips EXIF from image files which support it.

	Works by creating a new Image object which ignores exif by
	default and then extracts the binary data back into content.

	Returns: 
		Bytes: Stripped image content
	"""


	original_image = Image.open(io.BytesIO(content))
	output = io.BytesIO()
	
	new_image = Image.new(original_image.mode, original_image.size)
	new_image.putdata(list(original_image.getdata()))
	new_image.save(output, format=content_type.split('/')[1])
	
	content = output.getvalue()

	return content