Font color#26
Conversation
Adding two functions on to change font color and another for convert rgba color to accept format for ImageMagick command .
Adding format font color function to getDuelTextColor function.
Add miss function to prepare font color
| preg_match('/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/i', $hex, $rgb); | ||
|
|
||
| if ($rgb) { | ||
| if (!empty($rgb[4]) && \XF::options()->up_wm_opecity === 0) { |
There was a problem hiding this comment.
XF is not found. Can you please use an alternative that does not require additional installation?
There was a problem hiding this comment.
I'm sorry for that mistake maybe i forget to change that line because i use it in my project the line number 250 should be like this:
if (!empty($rgb[4])) {
| */ | ||
| public function setFontColor($fontColor) | ||
| { | ||
| $this->options['fontcolor'] = $this->_prepareColorForWaterMark($fontColor); |
There was a problem hiding this comment.
To make this function chainable, we should return $this.
| $this->options['fontcolor'] = $this->_prepareColorForWaterMark($fontColor); | |
| $this->options['fontcolor'] = $this->_prepareColorForWaterMark($fontColor); | |
| return $this; |
There was a problem hiding this comment.
You are correct I'm sorry i miss that.
| } else { | ||
| $hex = str_replace('#', '', $hex); | ||
|
|
||
| if (utf8_strlen($hex) == 3) { |
There was a problem hiding this comment.
utf8_strlen function is not found. Can we use mb_strlen() instead?
There was a problem hiding this comment.
I don't try that but to make utf8_strlen work you should to Install php-mbstring module on server and that's will solve this issue.
|
Assalamualaikum @shqawe1 , I am very happy that you've solved it and want to share the solution! 🤗 I was trying to test it and found a few tiny issues. Also, if you could list all the supported color formats that will work after merging this, that would be very much helpful. Thanks a lot, brother! |
|
First of all i want you to accept my apologize for these mistakes because i wrote it quickly as copy paste from my project. About the color format the code accept rgb & rgba formats.
|
|
Are there any plans to merge this? I want to use it for a project but could not do so without this functionality. |
Add new function with name setFontColor to have ability to change font color. and this function accepting just RGB & RGBA format.
Example:
`$watermark->setFont('Arial')
->setFontSize(36)
->setOpacity(.4)
->setRotate(330)
->setFontColor('rgba(255, 255, 255,0)')
->setOffset(-80, 200)
->setPosition(Watermark::POSITION_RIGHT);
$text = "ajaxray.com";
$watermark->withText($text, DIR.'/img/result_simple.jpg');`