Skip to content

Instantly share code, notes, and snippets.

View carzacc's full-sized avatar

Carmine Zaccagnino carzacc

View GitHub Profile
class UploadPage extends StatefulWidget {
UploadPage({Key key, this.url}) : super(key: key);
final String url;
@override
_UploadPageState createState() => _UploadPageState();
}
class _UploadPageState extends State<UploadPage> {
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:http/http.dart' as http;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
(String filename, String url) async {
var request = http.MultipartRequest('POST', Uri.parse(url));
request.files.add(
await http.MultipartFile.fromPath(
'picture',
filename
)
);
var res = await request.send();
}
(String filename, String url) async {
var request = http.MultipartRequest('POST', Uri.parse(url));
request.files.add(
http.MultipartFile.fromBytes(
'picture',
File(filename).readAsBytesSync(),
filename: filename.split("/").last
)
);
var res = await request.send();
(String filename, String url) async {
var request = http.MultipartRequest('POST', Uri.parse(url));
request.files.add(
http.MultipartFile(
'picture',
File(filename).readAsBytes().asStream(),
File(filename).lengthSync(),
filename: filename.split("/").last
)
);
import argparse
import actions
parser = argparse.ArgumentParser(
description="Improve the way you look at your picture collection with this simple CLI tool"
)
subparsers = parser.add_subparsers()
generate = subparser.add_parser("generate", help="Generate the pictures")
@carzacc
carzacc / actions.py
Last active November 18, 2019 15:32
from imageprocessor import ImageProcessor
def process_dir(args):
"""
Process the images: copy them so that
you can recognize what directory
they came from both from their name
and from the text annotated over them.
"""
from wand.image import Image
from wand.drawing import Drawing
import os
from sys import argv
from shutil import copyfile
class ImageProcessor:
"""
The interface between our tool and
the Wand library
@carzacc
carzacc / onpressedmain.dart
Last active February 9, 2019 21:28
image_picker guide
onPressed: () async {
var imgFile = await ImagePicker.pickImage(
source: ImageSource.camera
);
setState((){
imgs.add(Image.file(imgFile));
});
}
@carzacc
carzacc / homepagelayoutmain.dart
Created February 9, 2019 21:23
image_picker guide
class PictureShowcaseHome extends StatefulWidget {
final String title;
PictureShowcaseHome(this.title);
_HomePageState createState() => _HomePageState();
}