fixOrientation(); } return $layer; } /** * Initialize a text layer * * @param string $text * @param string $fontPath * @param integer $fontSize * @param string $fontColor * @param integer $textRotation * @param integer $backgroundColor * * @return ImageWorkshopLayer */ public static function initTextLayer($text, $fontPath, $fontSize = 13, $fontColor = 'ffffff', $textRotation = 0, $backgroundColor = null) { $textDimensions = ImageWorkshopLib::getTextBoxDimension($fontSize, $textRotation, $fontPath, $text); $layer = static::initVirginLayer($textDimensions['width'], $textDimensions['height'], $backgroundColor); $layer->write($text, $fontPath, $fontSize, $fontColor, $textDimensions['left'], $textDimensions['top'], $textRotation); return $layer; } /** * Initialize a new virgin layer * * @param integer $width * @param integer $height * @param string $backgroundColor * * @return ImageWorkshopLayer */ public static function initVirginLayer($width = 100, $height = 100, $backgroundColor = null) { $opacity = 0; if (null === $backgroundColor || $backgroundColor == 'transparent') { $opacity = 127; $backgroundColor = 'ffffff'; } return new ImageWorkshopLayer(ImageWorkshopLib::generateImage($width, $height, $backgroundColor, $opacity)); } /** * Initialize a layer from a resource image var * * @param \resource $image * * @return ImageWorkshopLayer */ public static function initFromResourceVar($image) { return new ImageWorkshopLayer($image); } /** * Initialize a layer from a string (obtains with file_get_contents, cURL...) * * This not recommanded to initialize JPEG string with this method, GD displays bugs ! * * @param string $imageString * * @return ImageWorkshopLayer */ public static function initFromString($imageString) { if (!$image = @imageCreateFromString($imageString)) { throw new ImageWorkshopException('Can\'t generate an image from the given string.', static::ERROR_CREATE_IMAGE_FROM_STRING); } return new ImageWorkshopLayer($image); } }