Skip to content

Instantly share code, notes, and snippets.

@duanebester
Last active May 31, 2018 20:12
Show Gist options
  • Select an option

  • Save duanebester/8fc123732477cee2e3517d37ec13612b to your computer and use it in GitHub Desktop.

Select an option

Save duanebester/8fc123732477cee2e3517d37ec13612b to your computer and use it in GitHub Desktop.
val route =
path("image" / "process") {
post {
fileUpload("fileUpload") {
case (_, fileStream) =>
val inputStream = fileStream.runWith(StreamConverters.asInputStream())
val image: BufferedImage = ImageIO.read(inputStream)
val preProcessed: Source[ByteString, NotUsed] = Source
.single(image)
.via(imageToBinaryImage)
.via(imageDeSkew())
.via(imageWriter())
complete(HttpEntity(ContentType.Binary(MediaTypes.`image/png`), preProcessed))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment