# `resizeService`
service in module `images-resizer`

## Description

Main service which resize images and so on

## Methods

- ### calulateImageSize(imgString, outputFormat)

  Return the size of the img by given the base64 img strings.

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  imgString | string | String base64 image
  outputFormat | string | string the format of the output file for example image/jpeg, image/png,...

  ##### Returns

  number | size of the img

- ### createImage(src, crossOrigin)

  Creates a new image object according to a source

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  src | string | Attribute of an img element
  crossOrigin | boolean | Add the possibility to import cross origin images

  ##### Returns

  Object | A promise with the image

- ### resizeCanvas(cnv, width, height)

  Resize a canvas according to the width and height

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  cnv | Object | the canvas
  width | number | the final width to resize the canvas
  height | number | the final height to resize the canvas

  ##### Returns

  Object | return the resized canvas

- ### resizeImage(src, options)

  Resize an image with a given src attribute

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  src | string | string src attribute of an img element
  options | object | json contain all options to resize an image (see all options available directly in th code below)

  ##### Returns

  promise | when the work is done it return the image or an error :)

- ### resizeImageBySize(image, size, outputFormat)

  Resize image to the approximately absolute size in octet

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  image | Object | htmlImage the miage to resize
  size | number | number the final size in octet
  outputFormat | string | string the format of the output file for example image/jpeg, image/png,...

  ##### Returns

  string | resize image in base64

- ### resizeImageWidthHeight(image, width, height, step, outputFormat)

  Resize image according to the width or the height or both

  ##### Parameters

  Param | Type | Details
  --- | --- | ---
  image | Object | DomImage html image to resize
  width | number | desired final image width
  height | number | integer desired final image height
  step | number | integer the number of step to finally have the image to the desired size
  outputFormat | string | string the format of the output file for example image/jpeg, image/png,...

  ##### Returns

  string | resized image in base64