Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError (index): Index out of range: index should be less than 89752: 1701999736 #0 Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7) #690

Open
insinfo opened this issue Oct 24, 2024 · 4 comments

Comments

@insinfo
Copy link

insinfo commented Oct 24, 2024

I'm having trouble decoding jpeg images

Future<WpImage?> insereImage(int autorId, File imageFile,
    {DateTime? data, String? legenda, String? siteUrl}) async {
  final basePath = basePathUploads;
  final now = DateTime.now();
  // post_date
  final dataPub = data ?? now;
  // Data em UTC
  final dataPubUtc = dataPub.toUtc().subtract(Duration(hours: 3));

  final ano = dataPubUtc.year;
  final mes = dataPubUtc.month;

  final siteFullurl = siteUrl ?? await getSiteUrl();

  final nomeImagemOriginal = path.basename(imageFile.path);

  final mimeType = mime(nomeImagemOriginal);

  if (mimeType == null) {
    throw Exception('Não foi possivel obter mimeType do arquivo');
  }

  final fileExtension = path.extension(nomeImagemOriginal);
  final fileName = path.basenameWithoutExtension(nomeImagemOriginal);

  Image imageOriginal;
  try {
    final imageOriginalBytes = await imageFile.readAsBytes();
    imageOriginal = decodeNamedImage(imageFile.path, imageOriginalBytes)!;
  } catch (e, s) {
    print('erro ao decodificar imagem ${imageFile.path} $e $s');
    return null;
  }
...
erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2716.jpg RangeError (index): Index out of range: index should be less than 89752: 1701999736 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2717.jpg RangeError (index): Index out of range: index should be less than 24882: 65957 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2715.jpg RangeError (index): Index out of range: index should be less than 31398: 694642044 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2715_2.jpg RangeError (index): Index out of range: index should be less than 27200: 1701838860 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2721_2.jpg RangeError (index): Index out of range: index should be less than 33784: 33784 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint32 (package:image/src/util/input_buffer.dart:194:22)
#2      ExifData._readEntry (package:image/src/exif/exif_data.dart:331:25)
#3      ExifData.read.<anonymous closure> (package:image/src/exif/exif_data.dart:279:30)
#4      new _GrowableList.generate (dart:core-patch/growable_array.dart:136:28)
#5      ExifData.read (package:image/src/exif/exif_data.dart:278:19)
#6      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#7      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#8      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#9      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#10     JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#11     decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#12     insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#13     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#14     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2721_3.jpg RangeError (index): Index out of range: index should be less than 29072: 262156 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2726.jpg RangeError (index): Index out of range: index should be less than 90650: 1935438718 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2726_2.jpg RangeError (index): Index out of range: index should be less than 29015: 786444 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2719.jpg RangeError (index): Index out of range: index should be less than 34604: 6816105 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData.read (package:image/src/exif/exif_data.dart:277:32)
#3      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#4      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#5      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#6      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#7      JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#8      decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#9      insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)
<asynchronous suspension>
#10     importaNoticias (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:430:25)
<asynchronous suspension>
#11     main (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:403:3)
<asynchronous suspension>

erro ao decodificar imagem Z:/desenvolvimento/backups/SiteAntigoPMRO_16.12.16/Portal 3.0/img/n2725.jpg RangeError (index): Index out of range: index should be less than 29083: 3085975044 #0      Uint8List.[] (dart:typed_data-patch/typed_data_patch.dart:2259:7)
#1      InputBuffer.readUint16 (package:image/src/util/input_buffer.dart:167:22)
#2      ExifData._readEntry (package:image/src/exif/exif_data.dart:329:23)
#3      ExifData.read.<anonymous closure> (package:image/src/exif/exif_data.dart:279:30)
#4      new _GrowableList.generate (dart:core-patch/growable_array.dart:136:28)
#5      ExifData.read (package:image/src/exif/exif_data.dart:278:19)
#6      JpegData._readExifData (package:image/src/formats/jpeg/jpeg_data.dart:319:10)
#7      JpegData._readAppData (package:image/src/formats/jpeg/jpeg_data.dart:345:7)
#8      JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:205:11)
#9      JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
#10     JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:48:30)
#11     decodeNamedImage (package:image/src/formats/formats.dart:241:20)
#12     insereImage (file:///C:/MyDartProjects/pg_query/examples/high_level/web_scraping.dart:594:21)

n2723_2
n2725
n2738
n2739

photos.zip

@insinfo
Copy link
Author

insinfo commented Oct 24, 2024

image: ^4.3.0
Dart SDK version: 3.2.1

@brendan-duncan
Copy link
Owner

Thanks for the repo photos, I'll take a look

@brendan-duncan
Copy link
Owner

I pushed a fix to git

@byte-art
Copy link

I pushed a fix to git

extension WebExtension on String {
///传入本地图片路径,判断是否webp动图
Future get isAnimatedWebp async {
try {
final image = await img.decodeWebPFile(this);
return (image?.frames.length ?? 0) > 1;
} catch (e) {
Logger.native('isAnimatedWebp $e');
return false;
}
}
}

Got same problem.

Flutter SDK:3.22.2
Dart Version:3.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants