Adding text | image-go | Spatie       

 SPATIE  

image-go
========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Image-go](https://spatie.be/docs/image-go/v1)  Image-manipulations  Adding text

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/image-go/v1) 

  Adding text    
- [ Introduction ](https://spatie.be/docs/image-go/v1/introduction)
- [ Postcardware ](https://spatie.be/docs/image-go/v1/postcardware)
- [ Installation and setup ](https://spatie.be/docs/image-go/v1/installation-and-setup)
- [ Supported formats ](https://spatie.be/docs/image-go/v1/formats)
- [ Questions &amp; issues ](https://spatie.be/docs/image-go/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/image-go/v1/changelog)
- [ About us ](https://spatie.be/docs/image-go/v1/about-us)
- [ Upgrading ](https://spatie.be/docs/image-go/v1/upgrading)
- [ Testing ](https://spatie.be/docs/image-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/image-go/v1/releasing)

Usage
-----

- [ Basic usage ](https://spatie.be/docs/image-go/v1/usage/basic-usage)
- [ Saving images ](https://spatie.be/docs/image-go/v1/usage/saving-images)
- [ Retrieving properties ](https://spatie.be/docs/image-go/v1/usage/retrieving-properties)
- [ Colors ](https://spatie.be/docs/image-go/v1/usage/colors)

Image manipulations
-------------------

- [ Overview ](https://spatie.be/docs/image-go/v1/image-manipulations/overview)
- [ Resizing images ](https://spatie.be/docs/image-go/v1/image-manipulations/resizing-images)
- [ Optimizing images ](https://spatie.be/docs/image-go/v1/image-manipulations/optimizing-images)
- [ Adjustments ](https://spatie.be/docs/image-go/v1/image-manipulations/adjustments)
- [ Image canvas ](https://spatie.be/docs/image-go/v1/image-manipulations/image-canvas)
- [ Effects ](https://spatie.be/docs/image-go/v1/image-manipulations/effects)
- [ Adding a watermark ](https://spatie.be/docs/image-go/v1/image-manipulations/adding-a-watermark)
- [ Adding text ](https://spatie.be/docs/image-go/v1/image-manipulations/text)

 Adding text
===========

###  On this page 

1. [ Text position ](#content-text-position)
2. [ Font size ](#content-font-size)
3. [ Font color ](#content-font-color)
4. [ Font family ](#content-font-family)
5. [ Wrapping text ](#content-wrapping-text)

Using `Text` you can position and add text. By default, it is placed in the top left corner:

```
photo.Text("Hello there!", image.TextOptions{FontSize: 24})
```

Text position
-----------------------------------------------------------------------------------------------

Use `X` and `Y` to set the text layer's top-left pixel position. `Angle` rotates that layer clockwise:

```
photo.Text("Hello there!", image.TextOptions{FontSize: 24, X: 10, Y: 10})
```

Unlike PHP Imagick's baseline coordinates, this API uses the top left of the rendered text layer.

Font size
-----------------------------------------------------------------------------------

Set `FontSize` in pixels. A positive size is required:

```
photo.Text("Hello there!", image.TextOptions{FontSize: 100})
```

Font color
--------------------------------------------------------------------------------------

Set `Color` to a name or hexadecimal RGB(A). The default is black:

```
photo.Text("Hello there!", image.TextOptions{FontSize: 24, Color: "007698"})
```

Font family
-----------------------------------------------------------------------------------------

Use `FontPath` for a portable font choice. An empty path uses ImageMagick's configured default font, which may not exist on a minimal server:

```
photo.Text("Hello there!", image.TextOptions{FontSize: 24, FontPath: "fonts/arial.ttf"})
```

Font paths are trusted application configuration. Text is treated literally, without ImageMagick property expansion or indirect file reads.

Wrapping text
-----------------------------------------------------------------------------------------------

Use `Width` to define a maximum line width in pixels. Text wraps on word boundaries using measured font widths. Existing newlines remain, and individual long words are not split:

```
options := image.TextOptions{FontSize: 24, FontPath: "fonts/arial.ttf", Width: 500}
photo.Text("Hello there! This is a long piece of text that we should wrap.", options)
wrapped, err := photo.WrapText("Hello there! This is another line.", options)
```

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
