in src/google/appengine/api/images/__init__.py [0:0]
def _update_dimensions(self):
"""Updates the `width` and `height` fields of the image.
Raises:
NotImageError: If the image data is not an image.
BadImageError: If the image data is corrupt.
"""
if not self._image_data:
raise NotImageError("Dimensions unavailable for blob key input")
size = len(self._image_data)
if size >= 6 and self._image_data.startswith(b"GIF"):
self._update_gif_dimensions()
self._format = GIF
elif size >= 8 and self._image_data.startswith(b"\x89PNG\x0D\x0A\x1A\x0A"):
self._update_png_dimensions()
self._format = PNG
elif size >= 2 and self._image_data.startswith(b"\xff\xD8"):
self._update_jpeg_dimensions()
self._format = JPEG
elif (size >= 8 and (self._image_data.startswith(b"II\x2a\x00") or
self._image_data.startswith(b"MM\x00\x2a"))):
self._update_tiff_dimensions()
self._format = TIFF
elif size >= 2 and self._image_data.startswith(b"BM"):
self._update_bmp_dimensions()
self._format = BMP
elif size >= 4 and self._image_data.startswith(b"\x00\x00\x01\x00"):
self._update_ico_dimensions()
self._format = ICO
elif (size >= 16 and (self._image_data.startswith(b"RIFF", 0, 4) and
self._image_data.startswith(b"WEBP", 8, 12) and
self._image_data.startswith(b"VP8 ", 12, 16))):
self._update_webp_dimensions()
self._format = WEBP
elif (size >= 16 and (self._image_data.startswith(b"RIFF", 0, 4) and
self._image_data.startswith(b"WEBP", 8, 12) and
self._image_data.startswith(b"VP8X", 12, 16))):
self._update_webp_vp8x_dimensions()
self._format = WEBP
else:
raise NotImageError("Unrecognized image format")