decodeImage method

  1. @override
Image? decodeImage(
  1. List<int> bytes, {
  2. int frame = 0,
})
override

Decode the file and extract a single image from it. If the file is animated, the specified frame will be decoded. If there was a problem decoding the file, null is returned.

Implementation

@override
Image? decodeImage(List<int> bytes, {int frame = 0}) {
  final jpeg = JpegData();
  jpeg.read(bytes);

  if (jpeg.frames.length != 1) {
    throw ImageException('only single frame JPEGs supported');
  }

  return jpeg.getImage();
}