Created
April 13, 2019 05:00
-
-
Save plateaukao/e9142028fb3a89df67e3c8ada74af1fb to your computer and use it in GitHub Desktop.
flutter_image_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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