image_size_getter 0.3.0 copy "image_size_getter: ^0.3.0" to clipboard
image_size_getter: ^0.3.0 copied to clipboard

outdated

Get image width and height, the library does not completely decode the image file, just read the metadata to get the image width and height.

image_size_getter #

Do not completely decode the image file, just read the metadata to get the image width and height.

Just support jpeg, gif, png, webp.

Usage #

import 'dart:io';

import 'package:image_size_getter/image_size_getter.dart';
import 'package:image_size_getter/file_input.dart'; // For compatibility with flutter web.

void main(List<String> arguments) async {
  final file = File('asset/IMG_20180908_080245.jpg');
  final size = ImageSizeGetter.getSize(FileInput(file));
  print('jpg = $size');

  final pngFile = File('asset/ic_launcher.png');
  final pngSize = ImageSizeGetter.getSize(FileInput(pngFile));
  print('png = $pngSize');

  final webpFile = File('asset/demo.webp');
  final webpSize = ImageSizeGetter.getSize(FileInput(webpFile));
  print('webp = $webpSize');

  final gifFile = File('asset/dialog.gif');
  final gifSize = ImageSizeGetter.getSize(FileInput(gifFile));
  print('gif = $gifSize');
}

MemoryImage

import 'package:image_size_getter/image_size_getter.dart';

void foo(Uint8List image){
  final memoryImageSize = ImageSizeGetter.getSize(MemoryInput(image));
  print('memoryImageSize = $memoryImageSize');
}

migrate #

See migrate

Other question #

The package is dart package, no just flutter package. So, if you want to get flutter asset image size, you must convert it to memory(Uint8List).

final buffer = await rootBundle.load('assets/logo.png'); // get the byte buffer
final memoryImageSize = ImageSizeGetter.getSize(MemoryInput.byteBuffer(buffer));
print('memoryImageSize = $memoryImageSize');

LICENSE #

Apache 2.0

135
likes
30
points
540k
downloads

Publisher

verified publisherfluttercandies.com

Weekly Downloads

Get image width and height, the library does not completely decode the image file, just read the metadata to get the image width and height.

Repository (GitHub)
Contributing

License

Apache-2.0 (license)

Dependencies

collection, hashcodes

More

Packages that depend on image_size_getter