SoPHIE API Documentation

Image API Documentation

SoPHIELabs Image API Class

The Image API provides a way to work with images files and to create dynamic images using the localfile api to do so.

Init: $imageApi = $api->get('sophielabs_image');

Method: $imageApi->getWidth(...)

Returns image width

Parameters:

  • String $fileName String with source file name (relative path)

Returns Float with image width

Method: $imageApi->getHeight(...)

Returns image height

Parameters:

  • String $fileName String with source file name (relative path)

Returns Float with image height

Method: $imageApi->getInfo(...)

Returns image specifications like width, height and file type

Parameters:

  • String $fileName String with source file name (relative path)

Returns Array with image specifications

Method: $imageApi->resize(...)

Resizes an image based on the given parameters (Caution: the image gets stretched or compressed if the new sizes do not match the original photos format)

Parameters:

  • String $fileName String with source file name (relative path)
  • String $fileNameTarget String with target file name (relative path)
  • Float $newWidth Float with width of resulting image
  • Float $newHeight Float with height of resulting image

Method: $imageApi->centerCrop(...)

Crops the center of an image based on the new size format and resizes the image

Parameters:

  • String $fileName String with source file name (relative path)
  • String $fileNameTarget String with target file name (relative path)
  • Float $newWidth Float with width of resulting image
  • Float $newHeight Float with height of resulting image