-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font color #26
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XF is not found. Can you please use an alternative that does not require additional installation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utf8_strlen
function is not found. Can we use mb_strlen()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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');`