Table of Contents
Shortcuts

# encode_png

torchvision.io.encode_png(input: Tensor, compression_level: int = 6) → Tensor

  Takes an input tensor in CHW layout and returns a buffer with the contents of its corresponding PNG file.

  Parameters:

    - input (Tensor[channels, image_height, image_width]) – int8 image tensor of `c` channels, where `c` must 3 or 1.

    - compression_level (int) – Compression factor for the resulting file, it must be a number between 0 and 9. Default: 6

  Returns:

    A one dimensional int8 tensor that contains the raw bytes of the

      PNG file.

  Return type:

    Tensor[1]

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.