png_write_meta

lib.image.png_write_meta(image: bytes, data: PNGHeader | dict[str, Any] | bytes) bytes

Write Faceswap information to a png’s iTXt field.

Parameters:
  • image (bytes) – The bytes encoded png file to write header data to

  • data (PNGHeader | dict[str, Any] | bytes) – The dictionary to write to the header. Can be pre-encoded as utf-8.

Return type:

bytes

Notes

This is a fairly stripped down and non-robust header writer to fit a very specific task. OpenCV will not write any iTXt headers to the PNG file, so we make the assumption that the only iTXt header that exists is the one that we created for storing alignments.

References

PNG Specification: https://www.w3.org/TR/2003/REC-PNG-20031110/