import struct
import binascii


def make_chunk(type, data):
	"""Create a raw chunk by composing chunk's ``type`` and ``data``. It
	calculates chunk length and CRC for you.

	:arg str type: PNG chunk type.
	:arg bytes data: PNG chunk data, **excluding chunk length, type, and CRC**.
	:rtype: bytes
	"""
	out = struct.pack("!I", len(data))
	data = type.encode("latin-1") + data
	out += data + struct.pack("!I", binascii.crc32(data))
	return out