play! scala file resource handling and image resizing

0 %
100 %
Information about play! scala file resource handling and image resizing
Technology

Published on February 20, 2014

Author: 3x14159265

Source: slideshare.net

Description

file resource and image resize plugin for play! 2 framework in scala. storing files like amazon s3 bucket and resize images on the fly.

file resource handling & image resizing in play! (scala) by david pichsenmeister

play-res & play-scalr for play! framework 2 developed by @LeonRadley

play-res like amazon s3 bucket computes sha1 hash of file and uses it as pathname

dependencies val appDependencies = Seq( "se.digiplant" %% "play-res" % "1.0" ) val main = play.Project(appName, appVersion, appDependencies).settings( // to simplify the reverse routing templatesImport ++= Seq("se.digiplant._") )

conf/application.conf # Resource plugin save directory # is relative to app, but can be absolute to filesystem also res.default=res res.images=res/images conf/routes GET /res/:file se.digiplant.res.ResAssets.at(file) GET /images/:file se.digiplant.res.ResAssets.at(file,“images”)

upload def upload = SecuredAction(true) { implicit request => val file = for { body <- request.body.asMultipartFormData uploaded <- body.file("file") } yield uploaded file match { case Some(f) => { val id: String = Res.put(f.ref.file) Ok(Json.obj("url" -> id)) } case _ => BadRequest } }

reverse routing <img src="@res.routes.ResAssets.at ("5564ac5e3968e77b4022f55a23d36630bdeb0274.jpg")" alt="" /> <img src="@res.routes.ResAssets.at ("5564ac5e3968e77b4022f55a23d36630bdeb0274.jpg", "images")" alt="" /> direct http://www.sharedspaces. at/res/cf342662c630a41f0dcf19314a35f82e5abbc9c4.jpg

play-scalr image resizing “on-the-fly” http://sharedspaces.at/{{width}}/{{height}}/ {{mode}}/file.jpg different modes: ● ● ● ● ● automatic fit_exact fit_to_width fit_to_height crop

dependencies val appDependencies = Seq( "se.digiplant" %% "play-scalr" % "1.0.1" ) conf/application.conf # define cache, so they only need to be resized once res.scalrcache=res/scalr # Tell scalr to use scalrcache source we just created scalr.cache=scalrcache conf/routes GET /res/:width/:height/:mode/:file se.digiplant. scalr.ScalrResAssets.at(width: Int, height: Int, mode: String, file)

reverse routing <img src="@scalr.routes.ScalrResAssets.at ("5564ac5e3968e77b4022f55a23d36630bdeb0274.jpg", 150, 100, "crop")" alt="" /> direct http://www.sharedspaces. at/res/150/100/crop/cf342662c630a41f0dcf19314a35f82e5abbc9c 4.jpg

resources http://leon.radley.se/project/ https://github.com/digiPlant/play-res https://github.com/digiPlant/play-scalr

thanks! feel free to add me on: .../3x14159265

Add a comment

Related presentations

Related pages

Play Framework - Build Modern & Scalable Web Apps with ...

Play Framework makes it easy to ... Play provides predictable and minimal resource ... Scale predictably. Underneath the covers Play uses a fully ...
Read more

c# - Resize image in WPF - Stack Overflow

Image Resize while file upload. Related. ... Memory Leak in WPF Image Resizing. 0 WPF ... How do I remove unused resources from 3rd party libraries I’ve ...
Read more

Resizing an Image On-The-Fly using .NET - CodeProject

Resizing an Image On-The-Fly ... along with any associated source code and files, ... I am new to VB.NET coding and really trying to get my head ...
Read more

PHP: imagecopyresized - Manual

Handling file uploads ... This Class image resize or crop, ... for resizing images in my gallery.
Read more

Resizing images - Online video tutorials & training ...

Resizing images From: Photoshop CS5 for ... Setting up color and file handling preferences; Resizing images; ... or pop the player out of the page into ...
Read more

Resizing image dynamically using C# - CodeProject

Resizing image dynamically using C#. ... The image handling will be processed in ... along with any associated source code and files, ...
Read more

bitmap - How to resize Image in Android? - Stack Overflow

How to resize Image in Android? ... File file = new File(imagepath); try ... Resizing images in android and iOS. 3.
Read more

Photo Resize - Android Apps on Google Play

... effective Spent an hour on play store looking for a simple image resize ... files reduce the size and attach ... Image Resizer can resize ...
Read more

Resizing Images - Web design, photo editing and DTP ...

Resize (scale) an image for print. ... Image Resizing: ... Make sure you save your resampled image as a new file and be sure not to overwrite the original!
Read more