Class humhub\modules\file\libs\ImageConverter

Inheritancehumhub\modules\file\libs\ImageConverter
Available since version0.5

ImageConverter provides a simple interface for converting or resizing images.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
Resize() Resizes an given Image to an given Size humhub\modules\file\libs\ImageConverter
ResizeFile() Resizes the given file and saves the resized file under the name given by targetFile. humhub\modules\file\libs\ImageConverter
TransformToJpeg() Transforms given File to Jpeg humhub\modules\file\libs\ImageConverter
allocateMemory() Dynamically allocate enough memory to process the given image. humhub\modules\file\libs\ImageConverter
checkTransparent() humhub\modules\file\libs\ImageConverter
fixOrientation() humhub\modules\file\libs\ImageConverter
getGDImageByFile() Creates GD Image Resource by given Filename humhub\modules\file\libs\ImageConverter

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DEFAULT_MAX_ADDITIONAL_MEMORY_ALLOCATION 64 Max value of memory allowed to be allocated additional to the currently set memory limit in php.ini in MBytes. * humhub\modules\file\libs\ImageConverter
SETTINGS_NAME_MAX_MEMORY_ALLOCATION 'maxImageProcessingMemoryAllocation' humhub\modules\file\libs\ImageConverter

Method Details

Resize() public static method

Resizes an given Image to an given Size

Options Array:

 width - in px
 height - in px
 mode:
     force - creates image with given dimensions  (default)
     max - creates image with a maximum of given width / height
public static void Resize ( $sourceFile, $targetFile, $options = [] )
$sourceFile String
$targetFile String
$options Array
throws \yii\base\Exception
ResizeFile() public static method (available since version 1.3.11)

Resizes the given file and saves the resized file under the name given by targetFile.

See also humhub\modules\file\libs\ImageConverter::Resize().

public static void ResizeFile ( humhub\modules\file\models\File $file, $targetFile, $options = [] )
$file humhub\modules\file\models\File
$targetFile
$options array
throws \yii\base\Exception
TransformToJpeg() public static method

Transforms given File to Jpeg

public static void TransformToJpeg ( $sourceFile, $targetFile )
$sourceFile String
$targetFile String
allocateMemory() public static method

Dynamically allocate enough memory to process the given image.

public static boolean allocateMemory ( $sourceFile, $test false )
$sourceFile String

The source file.

$test boolean

If true the memory will not really be allocated and no exception will be thrown.

return boolean

True if sufficient memory is available.

throws \yii\base\Exception

if the memory is not sufficient to process the image.

checkTransparent() public static method

public static void checkTransparent ( $im )
$im
fixOrientation() public static method

public static void fixOrientation ( $image, $filename )
$image
$filename
getGDImageByFile() public static method

Creates GD Image Resource by given Filename

public static resource getGDImageByFile ( $fileName )
$fileName String
return resource

GD Image