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
Image Library text_watermark placement. #43
Comments
done! |
There's still a glitch with this code. Horizontal positioning is perfect, though the vertical position gets messed up. Corrected code: {{{ All I did was re-use the original CI font-size code to get the correct vertical bounding box dimensions. |
Thanks for your efforts guys. |
The vertical placement of text when using TTF's seems a bit erratic. On looking through the code for the text_watermark() method in Image_lib.php, I find:
{{{
!php
$fontwidth = $this->wm_font_size-($this->wm_font_size/4);
$fontheight = $this->wm_font_size;
$this->wm_vrt_offset += $this->wm_font_size;
}}}
On my develoment system, I've replaced this with the following using the php imagettfbbox function to determine the boundaries of the text. It seems to give a much more accurate result.
{{{
!php
$wm_text_box = imagettfbbox($this->wm_font_size,0,$this->wm_font_path,$this->wm_text);
$wm_text_width = $wm_text_box[2] - $wm_text_box[0];
$wm_text_height = $wm_text_box[1] - $wm_text_box[7];
$fontheight = $wm_text_height;
$fontwidth = $wm_text_width/strlen($this->wm_text);
$this->wm_vrt_offset += $fontheight;
}}}
The text was updated successfully, but these errors were encountered: