mod-image-resizer

Image resizer BusMod for Vert.x

License

License

GroupId

GroupId

fr.wseduc
ArtifactId

ArtifactId

mod-image-resizer
Last Version

Last Version

1.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

mod-image-resizer
Image resizer BusMod for Vert.x
Project URL

Project URL

https://github.com/web-education/mod-image-resizer
Source Code Management

Source Code Management

https://github.com/web-education/mod-image-resizer.git

Download mod-image-resizer

How to add to project

<!-- https://jarcasting.com/artifacts/fr.wseduc/mod-image-resizer/ -->
<dependency>
    <groupId>fr.wseduc</groupId>
    <artifactId>mod-image-resizer</artifactId>
    <version>1.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/fr.wseduc/mod-image-resizer/
implementation 'fr.wseduc:mod-image-resizer:1.5.0'
// https://jarcasting.com/artifacts/fr.wseduc/mod-image-resizer/
implementation ("fr.wseduc:mod-image-resizer:1.5.0")
'fr.wseduc:mod-image-resizer:jar:1.5.0'
<dependency org="fr.wseduc" name="mod-image-resizer" rev="1.5.0">
  <artifact name="mod-image-resizer" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.wseduc', module='mod-image-resizer', version='1.5.0')
)
libraryDependencies += "fr.wseduc" % "mod-image-resizer" % "1.5.0"
[fr.wseduc/mod-image-resizer "1.5.0"]

Dependencies

compile (4)

Group / Artifact Type Version
com.drewnoakes : metadata-extractor jar 2.10.1
org.imgscalr : imgscalr-lib jar 4.2
fr.wseduc : vertx-swift-client jar 0.1.0
org.mongodb : mongo-java-driver jar 2.12.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.10
io.vertx : testtools jar 2.0.0-final

Project Modules

There are no modules declared in this project.

Module Image Resizer

This module allows you to resize and save images. For reading and storing images, it can use the file system or GridFS.

Name

The module name is mod-image-resizer.

Configuration

FileSystem only

The mod-image-resizer module takes the following configuration:

{
	"address": <address>,
	"base-path": <base-path>
}

For example:

{
	"address": "image.resizer",
	"base-path": "/tmp/images"
}

Let's take a look at each field in turn:

  • address The main address for the module. Every module has a main address. Defaults to image.resizer.
  • base-path The root folder to read or write images.

Gridfs

The mod-image-resizer module takes the following configuration:

{
	"address": <address>,
	"gridfs": {
		"host" : <host>,
		"port" : <port>,
		"db_name" : <db>,
		"username" : <username>,
		"password" : <password>,
		"pool_size" : <pool_size>
	}
}

For example:

{
	"address" : "image.resizer",
	"gridfs" : {
		"host": "localhost",
		"port": 27017,
		"db_name": "one_gridfs",
		"pool_size": 10
	}
}

Let's take a look at each field in turn:

  • address The main address for the module. Every module has a main address. Defaults to image.resizer.
  • base-path The root folder to read or write images.
  • host Host name or ip address of the MongoDB instance. Defaults to localhost.
  • port Port at which the MongoDB instance is listening. Defaults to 27017.
  • db_name Name of the database in the MongoDB instance to use.
  • username MongoDB username.
  • password MongoDB password.
  • pool_size The number of socket connections the module instance should maintain to the MongoDB server. Default is 10.

File System + Grids example

{
	"address" : "image.resizer",
	"base-path": "/tmp/images",
	"gridfs" : {
		"host": "localhost",
		"port": 27017,
		"db_name": "one_gridfs",
		"pool_size": 10
	}
}

Operations

The module supports the following operations

Resize

Resize and store image.

To resize an image send a JSON message to the module main address:

{
	"action" : "resize",
	"src" : <src>,
	"dest" : <dest>,
	"width" : <width>,
	"height" : <height>,
	"stretch" : <stretch>
}

Where:

  • src is the source image. If src start with "file://" image is find in FS. Else if, src start with "gridfs://" image is find in GridFS. This field is mandatory.
  • dest is the destination image. If dest start with "file://" image is find in FS. Else if, dest start with "gridfs://" image is find in GridFS. This field is mandatory.
  • width is a number.
  • height is a number.
  • stretch is a boolean. When both width and height are specified, if stretch is false (default value) a crop is used to not stretch the image. But, if stretch is true resize not use crop and stretch image.

An example would be:

{
	"action" : "resize",
	"src" : "file://src/test/resources/img.jpg",
	"dest" : "gridfs://fs",
	"width" : 300
}

When the query complete successfully, a reply message is sent back to the sender with the following data:

{
	"status": "ok",
}

If an error occurs in saving the document a reply is returned:

{
	"status": "error",
	"message": <message>
}

Where

  • message is an error message.

Crop

Crop and store image.

Resize and store image.

To crop an image send a JSON message to the module main address:

{
	"action" : "crop",
	"src" : <src>,
	"dest" : <dest>,
	"width" : <width>,
	"height" : <height>,
	"x" : <x>,
	"y" : <y>
}

Where:

  • src is the source image. If src start with "file://" image is find in FS. Else if, src start with "gridfs://" image is find in GridFS. This field is mandatory.
  • dest is the destination image. If dest start with "file://" image is find in FS. Else if, dest start with "gridfs://" image is find in GridFS. This field is mandatory.
  • width is a number.
  • height is a number.
  • x is a number.
  • y is a number.

An example would be:

{
	"action" : "crop",
	"src" : "file://src/test/resources/img.jpg",
	"dest" : "file://crop500x500.jpg",
	"width" : 500,
	"height": 500,
	"x" : 50,
	"y" : 100
}

When the query complete successfully, a reply message is sent back to the sender with the following data:

{
	"status": "ok",
}

If an error occurs in saving the document a reply is returned:

{
	"status": "error",
	"message": <message>
}

Where

  • message is an error message.

Resize image in multiples sizes

Resize and store image in multiples sizes.

To resize image in multiples sizes send a JSON message to the module main address:

{
	"action" : "resizeMultiple",
	"src" : <src>,
	"destinations" : <destinations>
}

Where:

  • src is the source image. If src start with "file://" image is find in FS. Else if, src start with "gridfs://" image is find in GridFS. This field is mandatory.
  • destinations is an array of object with same attribute than resize. This field is mandatory.

An example would be:

{
	"action" : "resizeMultiple",
	"src" : "file://src/test/resources/img.jpg",
	"destinations" : [
		{
			"dest" : "file://wb300x300.jpg",
			"width" : 300,
			"height" : 300
		},{
			"dest" : "file://wb300x250.jpg",
			"width" : 300,
			"height" : 250
		},{
			"dest" : "file://wb0x200.jpg",
			"height" : 200
		}
	]
}

When the query complete successfully, a reply message is sent back to the sender with the following data:

{
	"status": "ok",
}

If an error occurs in saving the document a reply is returned:

{
	"status": "error",
	"message": <message>
}

Where

  • message is an error message.
fr.wseduc

Open Digital Education

Startup EdTech, notre vocation est de concevoir des solutions qui font évoluer les pratiques pédagogiques et favorisent la réussite scolaire

Versions

Version
1.5.0
1.4.0
1.3.0
1.2.1
1.2.0
1.1.0