Skip to content

Instantly share code, notes, and snippets.

@bmabir17
Last active December 8, 2018 20:42
Show Gist options
  • Save bmabir17/d87baf30e5b73d7aace752b520723031 to your computer and use it in GitHub Desktop.
Save bmabir17/d87baf30e5b73d7aace752b520723031 to your computer and use it in GitHub Desktop.
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));
}
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