Last active
December 8, 2018 20:42
-
-
Save bmabir17/d87baf30e5b73d7aace752b520723031 to your computer and use it in GitHub Desktop.
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 | |
//You can also use other file format like jpeg, webp,TIFF, PSD, GIF | |
var imageFile = new Io.File('test.png').readAsBytesSync(); | |
//decodeImage will identify the format of the image and | |
// decode the image accordingly | |
Image image = decodeImage(imageFile); | |
//----One liner ---// | |
// Image image = decodeImage(new Io.File('test.png').readAsBytesSync()); | |
// Resize the image | |
Image thumbnail = copyResize(image,120); | |
//save the resized image as png | |
//Can also be saved as jpeg, gif | |
new Io.File('thumbnail.png').writeAsBytesSync(encodePng(thumbnail)); | |
} |
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
name : hello | |
version: 0.0.1 | |
author : B M Abir <[email protected]> | |
dependencies: | |
image: ^2.0.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment