Skip to content

Instantly share code, notes, and snippets.

@plateaukao
Created April 13, 2019 05:00
Show Gist options
  • Save plateaukao/e9142028fb3a89df67e3c8ada74af1fb to your computer and use it in GitHub Desktop.
Save plateaukao/e9142028fb3a89df67e3c8ada74af1fb to your computer and use it in GitHub Desktop.
flutter_image_example
import 'dart:io' as Io;
import 'package:image/image.dart';
void main() {
// Read an image from file (webp in this case).
// decodeImage will identify the format of the image and use the appropriate
// decoder.
Image image = decodeImage(new Io.File('test.webp').readAsBytesSync());
// Resize the image to a 120x? thumbnail (maintaining the aspect ratio).
Image thumbnail = copyResize(image, 120);
// Save the thumbnail as a PNG.
new Io.File('thumbnail.png')
..writeAsBytesSync(encodePng(thumbnail));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment