> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Go media transformations

After you or your users have uploaded media assets to Cloudinary, you can deliver them via dynamic URLs. You can include instructions in your dynamic URLs that tell Cloudinary to transform your assets using a set of transformation actions. All transformations are performed automatically in the cloud and your transformed assets are automatically optimized before they are routed through a fast CDN to the end user for optimal user experience.

For example, you can resize and crop, add overlay images or concatenate videos, blur or pixelate faces, apply a large variety of special effects and filters, and apply settings to optimize your media and to deliver them responsively.

Cloudinary's Go SDK simplifies the generation of transformation URLs for easy embedding of assets in your Go application.

## Syntax overview

The Go SDK allows you to build URLs for delivering assets stored in your Cloudinary product environment, and optionally add transformations by passing them directly as strings.  This is enabled by the Go SDK's custom-defined objects which store information about a specified asset. 

Using the Go SDK, you can generate a delivery URL:

* Of the original asset.
* With transformations applied.
* With other modifications.

In order to achieve the desired edit or optimization of your asset using the Go SDK, you need to correctly formulate the desired transformation as a string and then pass it as a parameter. For example, if you want to set the height of your asset to 300 pixels and apply a cartoonify effect, you need to pass the string `c_scale,w_300/e_cartoonify` as the transformation parameter.
> **INFO**:
>
> For comprehensive coverage of all available URL transformation parameters and instructions about how formulate your transformation strings, see the [Transformation URL API reference](transformation_reference). For each transformation, you can expand the **Examples** section, select the **URL** tab, and copy the transformation string in red.
## Deliver and transform assets

The `@cloudinary/cloudinary-go` library makes it easy for you to create image URLs including any transformation parameters.

### Direct URL building

You can build an asset URL by:

1. [Instantiating](#1_determine_the_asset_type) an asset object using `cld.Image(PublicID)` or `cld.Video(PublicID)`.
2. [Customize or transform](#2_customize_and_transform_your_asset_delivery_url) your asset URL by passing parameters to the object.
3. Calling the `String()` method of the Go asset object to [return the delivery URL](#3_return_the_delivery_url).

```go
import(
    "fmt"
    "github.com/cloudinary/cloudinary-go/v2"
)

func main() {
    // Instantiate an object for the image with public ID "docs/sdk/go/maroon_hat"
    i, err := cld.Image("docs/sdk/go/maroon_hat")
    if err != nil {
        fmt.Println("error")
    }

    // Add the transformation
    i.Transformation = "f_auto/q_auto/c_fill,g_face,h_200,w_200/a_-15"

    // Generate and print the delivery URL
    myURL, err := i.String()
    fmt.Println(myURL)
    if err != nil {
        fmt.Println("error")
    }
}
```
The resulting URL, `myURL`, is:

![Sample image](https://res.cloudinary.com/demo/image/upload/f_auto/q_auto/c_fill,g_face,h_200,w_200/a_-15/v1639034832/docs/sdk/go/maroon_hat.jpg "with_url: true, with_code: false")

#### 1. Determine the asset type 

You can instantiate an object that will capture and provide access to all the information needed to build your asset's delivery URL.

Different object are used to instantiate assets of different types:

| Object | Asset type
| --- | --- 
`File` | used for raw assets 
`Image` | used for images
`Video` | used for videos
`Media` | used when the asset type is unknown. In this case, the AssetType can be [set dynamically](#2_configure_delivery_parameters).

Use the appropriate object for your asset type, and identify the asset you are instantiating by passing the object a public ID:

```go
img, err := cld.Image(PublicID)
```

#### 2. Customize and transform your asset delivery URL

The parameters described in the [Object parameters table](#object_parameters_table) are part of the object you instantiated. These parameters, automatically populated with the values of the asset you identified, contain the information needed to generate the asset's delivery URL:

##### Object parameters table 

| Parameter | Description 
| --- | --- 
AssetType | The type of asset (`raw`, `image`, or `video`), determined by the method you used to create the object (`File`, `Image`, or `Video`). For the `Media` object, the default AssetType is `image`, but you can [change this parameter dynamically](#assign_asset_type_dynamically). 
DeliveryType | Provides an indication about the way the asset will be delivered, although in most cases, the [delivery type](image_transformations#delivery_types) is determined at the time that the asset is stored in your product environment. The default delivery type is `upload`.
Transformation | Contains the transformation string, which, when appended to the delivery URL, programmatically modifies the original [image](image_transformations#overview) or [video](video_manipulation_and_delivery) asset, resulting in a newly generated (derived) media file based on the original. Note: For comprehensive coverage of all available URL transformations, see the [Transformation URL API reference](transformation_reference).
Version | Represents the timestamp of the upload and enables you to access the latest [version](advanced_url_delivery_options#asset_versions) of an asset, or backed-up versions of it.
PublicID | The unique identifier of the asset.
Suffix | A user-friendly, descriptive ending that you can add as a [suffix](advanced_url_delivery_options#dynamic_seo_suffixes) to the public ID in the delivery URL.
Config | The configuration parameters that you set globally for your SDK.

You can change parameters stored in the object to modify the delivery URL. For example, you can add a suffix, change the asset type, or change the asset version in the delivery URL. 

By assigning a string containing [transformation components](image_transformations#chained_transformations) to the `Transformation` parameter,  you can change, optimize, edit, and enhance the asset generated by the delivery URL. 

##### Dynamically assign an asset type

To instantiate an object and then dynamically assign it an AssetType:

```go
m, err := cld.Media("docs/sdk/go/play_time")

m.AssetType="video"

// URL: https://res.cloudinary.com/demo/video/upload/v1/docs/sdk/go/play_time
```

##### Change the version of an asset

To instantiate an image object and then change the version of the asset:

```go
i, err := cldImage("docs/sdk/go/")

i.Version = "v1639034812"

// URL: https://res.cloudinary.com/demo/image/upload/v1639034812/docs/sdk/go/apple
```

##### Assign a transformation

To instantiate an image object and then assign the `Transformation` parameter [transformation components](image_transformations#chained_transformations):

```go
i, err := cld.Image("docs/sdk/go/maroon_hat")

i.Transformation = "f_auto/q_auto/c_fill,g_face,h_250,w_250/e_sepia:80"

// URL: https://res.cloudinary.com/demo/image/upload/f_auto/q_auto/c_fill,g_face,h_250,w_250/e_sepia:80/v1/docs/sdk/go/maroon_hat

```

In the above example:

* `f_auto` and `q_auto` optimize the format and quality of the image automatically 
* `c_fill` crops the image while keeping its aspect ratio 
* `g_face` keeps the image focused on the face after cropping
* `w_250` and `h_250` set the width and height of the transformed image to 250px
* `e.sepia` applies a special effect called "sepia" to the image. 
> **INFO**:
>
> For comprehensive coverage of all available URL transformation parameters and instructions about how formulate your transformation strings, see the [Transformation URL API reference](transformation_reference). For each transformation, you can expand the **Examples** section, select the **URL** tab, and copy the transformation string in red.

#### 3. Return the delivery URL

If you added a transformation or modified the parameters of the object, the URL you generate will reflect those changes.

The following code generates the URL from the [example](#assign_a_transformation) above:

```go
myURL, err := i.String()
```

The resulting URL and image:

![Generated asset](https://res.cloudinary.com/demo/image/upload/f_auto/q_auto/c_fill,g_face,h_250,w_250/e_sepia:80/v1639034832/docs/sdk/go/maroon_hat "thumb: w_250,dpr_2, width:250, popup:true, with_url:true, with_code: false")

> **NOTE**: Your URL may contain some letters and numbers at the end of it. This indicates the asset [analytics](cloudinary_sdks#configuration_parameters).

### Combining transformations

Cloudinary supports powerful transformations. You can even combine multiple transformations together as part of a single transformation request, e.g. crop an image and add a border. In certain cases you may want to perform additional transformations on the result of the previous transformation request.

To support multiple transformations in a transformation URL, you can include multiple transformation components, each separated by a '/'. Each transformation component is applied to the result of the previous one. In Go, applying multiple transformations is achieved by simply adding the next transformation to your transformation string, and then [assigning](#2_configure_delivery_parameters) that value to the **Transformation** parameter of your asset object. The following example first crops the original image to a specific set of custom coordinates and then transforms the result so it fills a 130x100 rectangle:

Original image

Fill cropping with 'faces' gravity

```go
package main

import (
	"fmt"
	"github.com/cloudinary/cloudinary-go/v2"
)

func main() {

	// Add your Cloudinary credentials.
	cld, _ := cloudinary.NewFromParams(<cloud_name>, <api_key>, <api_secret>)

	// Instantiate an object for the image with public ID "docs/sdk/go/black_coat_portrait"
	img, err := cld.Image("docs/sdk/go/black_coat_portrait")
	if err != nil {
		fmt.Println("error")
	}

	// Add the transformation
	img.Transformation = "f_auto/q_auto/c_crop,h_350,w_300,x_1400,y_1200/c_fill,h_100,w_130"

	// Generate and print the delivery URL
	myURL, err := img.String()
	if err != nil {
		fmt.Println("error")
	}
	fmt.Println(myURL)

	//Output: https://res.cloudinary.com/demo/image/upload/f_auto/q_auto/c_crop,h_350,w_300,x_1400,y_1200/c_fill,h_100,w_130/v1/docs/sdk/go/black_coat_portrait
}
```

## Apply common image transformations

This section provides a brief overview of commonly used image transformation features, with examples and links to detailed documentation for further exploration:

* [Resizing and cropping](#resizing_and_cropping): Learn how to adjust image dimensions and focus on specific areas.
* [Converting to another image format](#converting_to_another_image_format): Discover how to change your images to different formats as needed.
* [Applying image effects and filters](#applying_image_effects_and_filters): Explore ways to enhance your images with various effects and filters.
* [Adding text and image overlays](#adding_text_and_image_overlays): Find out how to incorporate text and image overlays for customization.
* [Image optimizations](#image_optimizations): Understand techniques for improving image performance and load times.

This section serves as an introduction to the basics of image transformations with Go. For a comprehensive guide on implementing a wide array of transformations, see [Image transformations](image_transformations).

To view a complete list of supported image transformations and their usage, check out the [Transformation URL API Reference](transformation_reference).

> **TIP**: In each of the following examples, the transformation strings link to the Transformation Reference, which offers detailed explanations and a comprehensive list of all available transformations.

### Resizing and cropping

There are a variety of different ways to resize and/or crop your images, and to control the area of the image that is preserved during a crop. 

The following example shows an image cropped ([c_fill](transformation_reference#c_fill)) to a 350X350 square ([w_350](transformation_reference#w_width),[h_350](transformation_reference#h_height)) while keeping focus on the faces ([g_faces](transformation_reference#g_special_position)) in the image:

```go
// Instantiate an object for the image with public ID "docs/sdk/go/family_video
img_fam, err := cld.Image("docs/sdk/go/family_video")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_fam.Transformation = "c_fill,g_faces,h_300,w_300"

// Generate and print the delivery URL
myURL, err := img_fam.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/c_fill,g_faces,h_300,w_300/v1/docs/sdk/go/family_video

```

Original image

Fill cropping with 'faces' gravity

You can also use automatic gravity to determine what to keep in the crop automatically.

```go
// Instantiate an object for the image with public ID "basketball_in_net"
img_fam, err := cld.Image("basketball_in_net")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_fam.Transformation = "c_fill,g_auto,h_300,w_200"

// Generate and print the delivery URL
myURL, err := img_fam.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/c_fill,g_auto,h_300,w_200/basketball_in_net

```

Original image

Fill cropping with 'auto' gravity

For all the ways in which an image can be cropped, see the parameters under the [c (crop)](transformation_reference#c_crop_resize) section of the _Transformation URL Reference_.

For details on all resizing and cropping options, see [Image resizing and cropping](resizing_and_cropping).

### Converting to another image format

You can deliver any image uploaded to Cloudinary in essentially any image format. There are three ways to convert and deliver images in another format:

* Specify the image's public ID with the desired extension. 
* Explicitly set the desired format using the `Transformations` parameter. 
* Use the `auto` fetch_format to instruct Cloudinary to deliver the image in the most optimized format for each browser that requests it.

For example:

##### Deliver a .jpg file in .png format: 

```go
// Instantiate an object for the image with public ID "docs/sdk/go/cloud_castle"
img_fam, err := cld.Image("docs/sdk/go/cloud_castle")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_fam.Transformation = "f_png"

// Generate and print the delivery URL
myURL, err := img_fam.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/f_png/v1/docs/sdk/go/cloud_castle
```

##### Let Cloudinary select the optimal format for each browser: 

For example, in Chrome, this image may deliver in **.avif** or **.webp** format (depending on your product environment setup):

```go
// Instantiate an object for the image with public ID "cloud_castle" in folder "docs/sdk/go"
img_fam, err := cld.Image("docs/sdk/go/cloud_castle")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_fam.Transformation = "f_auto"

// Generate and print the delivery URL
myURL, err := img_fam.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/f_auto/v1/docs/sdk/go/cloud_castle
```

The above code generates a URL with the `f_auto` parameter:
  ![Let Cloudinary select the optimal format to deliver for each browser.](https://res.cloudinary.com/demo/image/upload/c_scale,w_350/f_auto/v1/docs/sdk/go/cloud_castle "with_code:false, with_url:true, with_image:false ")

For information about the relevant parameter, see the [f (format)](transformation_reference#c_crop_resize) section of the _Transformation URL Reference_.

For more details, see:

* [Delivering images in different formats](image_transformations#delivering_in_a_different_format)
* [Automatic format selection (f_auto)](image_optimization#automatic_format_selection_f_auto)
* [Tips and considerations for using f_auto](image_optimization#tips_and_considerations_for_using_f_auto)

### Applying image effects and filters

You can select from a large variety of image effects, enhancements, and filters to apply to your images. The available effects include various color balance and level effects, tinting, blurring, pixelating, sharpening, automatic improvement effects, artistic filters, image and text overlays, distortion and shape changing effects, outlines, backgrounds, shadows, and more.

For example, the code below applies a cartoonify effect ([e_cartoonify](transformation_reference#e_cartoonify)), rounding corners effect ([r_max](transformation_reference#r_round_corners)), and background color effect ([b_lightblue](transformation_reference#b_background)), and then crops and pads ([c_pad](transformation_reference#c_pad)) the image down to a height of 300 pixels.

```go
// Instantiate an object for the image with public ID "docs/sdk/go/actor" 
img_actor, err := cld.Image("docs/sdk/go/actor")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_actor.Transformation = "e_cartoonify/r_max/co_lightblue,e_outline:100/b_lightblue,c_pad,h_300"

// Generate and print the delivery URL
myURL, err := img_actor.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/e_cartoonify/r_max/co_lightblue,e_outline:100/b_lightblue,c_pad,h_300/v1/docs/sdk/go/actor 
```

![An image with several transformation effects](https://res.cloudinary.com/demo/image/upload/e_cartoonify/r_max/co_lightblue,e_outline:100/b_lightblue,c_pad,h_300/v1/docs/sdk/go/actor "thumb: w_200,dpr_2, width:200, with_code:false, with_url:false, popup:true")

For all the effects that can be applied to images, see the parameters under the [e (effect)](transformation_reference#e_effect) section of the _Transformation URL Reference_.

For more details on the available image effects and filters, see [Visual image effects and enhancements](effects_and_artistic_enhancements).

### Adding text and image overlays

You can add images and text as overlays on your main image. You can apply the same types of transformations on your overlay images as you can with any image and you can use gravity settings or x and y coordinates to control the location of the overlays. You can also apply a variety of transformations on text, such as color, font, size, rotation, and more.

For example, the code below overlays a couple's photo on a mug image ([l_nice_couple](transformation_reference#l_image_id)). The overlay photo is cropped using face detection ([g_faces](transformation_reference#g_special_position)) with adjusted color saturation ([e_saturation:50](transformation_reference#e_saturation)) and a vignette effect ([e_vignette](transformation_reference#e_vignette)) applied. The word love is added in a brown, fancy font ([l_text:Cookie_23_bold:Love,co_rgb:744700](transformation_reference#l_text)) and placed to fit the design ([x_-23,y_50](transformation_reference#x_y_coordinates)). Additionally, the final image is cropped ([c_crop,w_300,h_250,x_30](transformation_reference#c_crop_resize)) and the corners are rounded ([r_60](transformation_reference#r_round_corners)).

```go
//  Instantiate an object for the image with public ID "docs/sdk/go/coffee_cup"
img_coffee, err := cld.Image("docs/sdk/go/coffee_cup")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_coffee.Transformation = "w_400,h_250,c_fill,g_south/l_nice_couple,w_1.3,h_1.3,g_faces,c_crop,fl_region_relative/e_saturation:50/e_vignette/fl_layer_apply,w_100,r_max,g_center,y_15,x_-20/l_text:Cookie_23_bold:Love,co_rgb:744700/fl_layer_apply,x_-23,y_50/c_crop,w_300,h_250,x_30/r_60"

// Generate and print the delivery URL
myURL, err := img_coffee.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/image/upload/w_400,h_250,c_fill,g_south/l_nice_couple,w_1.3,h_1.3,g_faces,c_crop,fl_region_relative/e_saturation:50/e_vignette/fl_layer_apply,w_100,r_max,g_center,y_15,x_-20/l_text:Cookie_23_bold:Love,co_rgb:744700/fl_layer_apply,x_-23,y_50/c_crop,w_300,h_250,x_30/r_60/coffee_cup.png
```        

![An image with many transformations and overlays applied](https://res.cloudinary.com/demo/image/upload/w_400,h_250,c_fill,g_south/l_nice_couple,w_1.3,h_1.3,g_faces,c_crop,fl_region_relative/e_saturation:50/e_vignette/fl_layer_apply,w_100,r_max,g_center,y_15,x_-20/l_text:Cookie_23_bold:Love,co_rgb:744700/fl_layer_apply,x_-23,y_50/c_crop,w_300,h_250,x_30/r_60/coffee_cup.png "thumb: w_400,dpr_2, width:400, with_code:false, with_url:false, popup:true")

For all ways in which you can apply overlays to images, see the parameters under the [l (layer)](transformation_reference#l_layer) section of the _Transformation URL Reference_.

For more details on adding image overlays, see [Visual image effects and enhancements](layers).

### Image optimizations

By default, Cloudinary automatically performs certain optimizations on all transformed images. There are also a number of additional features that enable you to further optimize the images you use in your application. These include optimizations to image quality, format, and size, among others.

For example, you can use the `auto` value for the [fetch_format](transformation_reference#f_format) and [quality](transformation_reference#q_quality) attributes to automatically deliver the image in the format and quality that minimize file size while meeting the required quality level. In addition, resize the image to make it even lighter. Below, these parameters are applied, resulting in a 25.66 KB AVIF file (in Chrome) instead of a 1.34 MB JPG with no visible change in quality.

```go
// Instantiate an object for the image with public ID "docs/sdk/go/pond_reflect"
img_lake, err := cld.Image("docs/sdk/go/pond_reflect")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
img_lake.Transformation = "w_500/f_auto,q_auto"

// Generate and print the delivery URL
myURL, err := img_lake.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)
// Output: https://res.cloudinary.com/demo/image/upload/w_500/f_auto/q_auto/v1/docs/sdk/go/pond_reflect
```

![Efficient file size optimization using auto format and auto quality features](https://res.cloudinary.com/demo/image/upload/f_auto/q_auto/v1/docs/sdk/go/pond_reflect "thumb: w_400,dpr_2, width:400, with_code:false, with_url:false, popup:true")

For all ways in which you can apply overlays to images, see the parameters under the [q (quality)](transformation_reference#q_quality) and [f (format)](transformation_reference#f_format) sections of the _Transformation URL Reference_.

For an in-depth review of the many ways you can optimize your images, see [Image optimization](image_optimization).

## Apply common video transformations

This section provides a brief overview of commonly used video transformation features, along with examples and links to detailed documentation for further exploration:

* [Resizing and cropping videos](#resizing_and_cropping_videos): Learn how to adjust video dimensions and focus on specific scenes.
* [Concatenating videos](#concatenating_videos): Discover how to merge multiple video clips into one seamless file.
* [Trimming videos](#trimming_videos): Explore techniques to cut unwanted sections from your videos.
* [Adding video overlays](#adding_video_overlays): Find out how to incorporate text and image overlays for customization.
* [Adding video effects](#adding_video_effects): Understand how to enhance your videos with various effects for improved visual appeal.

This section serves as an introduction to the basics of video transformations with Go. For a comprehensive guide on implementing a wide array of transformations, see [Video transformations](video_manipulation_and_delivery).

To view a complete list of supported video transformations and their usage, check out the [Transformation URL API Reference](transformation_reference).

> **TIP**: In each of the following examples, the transformation strings link to the Transformation Reference, which offers detailed explanations and a comprehensive list of all available transformations.

### Resizing and cropping videos

There are a variety of different ways to resize and/or crop your videos, and to control the area of the video that is preserved during a crop. The following examples:

* crop the video to a specified dimension ([c_crop,h_800,w_750](transformation_reference#c_crop)) in a specified area ([x_200,y_450](transformation_reference#x_y_coordinates))
* resize the video to fit a specified height and width while padding the extra space ([c_pad,h_320,w_480](transformation_reference#c_pad)) with the original asset blurred playing in the background ([b_blurred:400:15](transformation_reference#e_blur)) to preserve the original aspect ratio.

```go
// Instantiate an object for the video with public ID "docs/sdk/go/play_time"
v_play_time, err := cld.Video("docs/sdk/go/play_time")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
v_play_time.Transformation = "b_blurred:400:15,c_pad,h_320,w_480"
	

// Generate and print the delivery URL
myURL, err := v_play_time.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/video/upload/b_blurred:400:15,c_pad,h_320,w_480/v1/docs/sdk/go/play_time
```

  
    
    
    
  
Original video

  
    
    
    
  
Keep centered<code>c_crop,x_200,y_450

  
    
    
    
  
Pad with blurred video<code>c_pad,b_blurred:380:15

For all the ways in which a video can be cropped, see the parameters under the [c (crop)](transformation_reference#c_crop_resize) section of the _Transformation URL Reference_ that are marked as supported for video.

For details on all resizing and cropping options, see [Resizing and cropping videos](video_resizing_and_cropping).

### Concatenating videos

You can concatenate videos with a variety of options, including concatenating only a portion of the videos, concatenating a video at the beginning or end of another, creating custom transitions between concatenated videos, and concatenating an image to a video.

The following example shows two videos shortened to 5 seconds each ([du_5](transformation_reference#du_duration)), the main video starting with an offset of 1 second ([so_1](transformation_reference#so_start_offset)), with both videos uniformly resized ([c_fill,h_200,w_300](transformation_reference#c_fill)) and concatenated ([fl_splice](transformation_reference#fl_splice)):

```go
// Instantiate an object for the video with public ID "docs/sdk/go/horse_race" 
v_races, err := cld.Video("docs/sdk/go/horse_race")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
v_races.Transformation = "c_fill,h_300,w_450/du_5.0,so_1/fl_splice,l_video:swimming_race/c_fill,h_300,w_450/du_5.0/fl_layer_apply"

// Generate and print the delivery URL
myURL, err := v_races.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/video/upload/c_fill,h_300,w_450/du_5.0,so_1/fl_splice,l_video:swimming_race/c_fill,h_300,w_450/du_5.0/fl_layer_apply/v1/docs/sdk/go/horse_race
```

  
    
    
    
  

For a detailed description of how to concatenate videos, see the [splice](transformation_reference#fl_splice) parameter of the [fl_flag](transformation_reference#fl_flag) section of the Transformation URL Reference.

For details on all the ways in which you can concatenate videos, see [Concatenating media](video_trimming_and_concatenating#concatenating_media).

### Trimming videos

When trimming your videos, you can determine when to start trimming, when to stop, and / or the duration of the trimmed video. 

The following example shows trimming a video to the section that starts at 3.5 seconds ([so_3.5](transformation_reference#so_start_offset)) with a duration of 5 seconds ([du_5](transformation_reference#du_duration)):

```go
// Instantiate an object for the video with public ID "docs/sdk/go/dog_mirror" 
v_dog, err := cld.Video("docs/sdk/go/dog_mirror")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
v_dog.Transformation = "c_scale,w_450/du_5.0,so_3.5"
	

// Generate and print the delivery URL
myURL, err := v_dog.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/video/upload/c_scale,w_450/du_5.0,so_3.5/v1/docs/sdk/go/dog_mirror
```

  
    
    
    
  

For all the ways in which a video can be trimmed, see the [so (start_offset)](transformation_reference#so_start_offset), [du (duration)](transformation_reference#du_duration), [eo (end_offset)](transformation_reference#eo_end_offset) parameters the _Transformation URL Reference_ that are marked as supported for video.

For more details on trimming videos, see [Trimming videos](video_trimming_and_concatenating#trimming_videos).

### Adding video overlays

You can add video, text, or image overlays onto your videos.

The following example shows one video scaled down ([c_scale,w_100](transformation_reference#c_scale)) and placed in the north-east corner ([g_north_east](transformation_reference#g_gravity)) as an overlay ([l_video:exercise2](transformation_reference#l_video)), starting 3 seconds after the main video starts playing ([so_3](transformation_reference#so_start_offset)):

```go
// Instantiate an object for the video with public ID "docs/sdk/go/exercise1"
v_exercise, err := cld.Video("docs/sdk/go/exercise1")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
v_exercise.Transformation = "c_scale,w_300/l_video:exercise2/c_fit,w_80/bo_2px_solid_blue/fl_layer_apply,g_north_east,so_2.0"

// Generate and print the delivery URL
myURL, err := v_exercise.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/video/upload/c_scale,w_300/l_video:exercise2/c_fit,w_80/bo_2px_solid_blue/fl_layer_apply,g_north_east,so_2.0/v1/docs/sdk/go/exercise1
```

  
    
    
    
  

For all the ways in which you can add video overlays, see the parameters under the [l (layer)](transformation_reference#l_layer) section of the _Transformation URL Reference_ that are marked as supported for video.

For more details on video overlays, see [Placing layers on videos](video_layers).

### Adding video effects

You can select from a large variety of video effects, enhancements, and filters to apply to your video. The available effects include speed, direction, and looping control, adding a progress indicator overlay, different transparency settings, AI generated preview, a variety of color balance and level effects, blurring, fading, and automatic improvement effects.

The following example shows a video that fades in and out ([e_fade:2000/e_fade:-4000](transformation_reference#e_fade)), loops twice ([e_loop:2](transformation_reference#e_loop)), and has a vignette filter applied ([e_vignette:50](transformation_reference#e_vignette)):

```go
// Instantiate an object for the video with public ID "docs/sdk/go/dog_garden"
v_dogarden, err := cld.Video("docs/sdk/go/dog_garden")
if err != nil {
	fmt.Println("error")
}

// Add the transformation
v_dogarden.Transformation = "c_scale,w_400/du_10.0/e_vignette:50/e_fade:2000/e_fade:-4000/e_loop:2"

// Generate and print the delivery URL
myURL, err := v_dogarden.String()
if err != nil {
	fmt.Println("error")
}
fmt.Println(myURL)

// Output: https://res.cloudinary.com/demo/video/upload/c_scale,w_400/du_10.0/e_vignette:50/e_fade:2000/e_fade:-4000/e_loop:2/v1/docs/sdk/go/dog_garden
```

![Vignette effect](https://res.cloudinary.com/Cloudinary/video/upload/w_400/du_10/e_vignette:50/e_fade:2000/e_fade:-4000/e_loop:2/v1/docs/sdk/go/dog_garden "with_code: false")

For all video effects, see the parameters under the [e (effect)](transformation_reference#e_effect) section of the _Transformation URL Reference_ that are marked as supported for video.

For an in-depth review of all the available video effects, see [Video Effects](video_effects_and_enhancements).

## Sample projects: Image and video transformations

Explore two sample Go apps that demonstrate how to apply common transformations to images and videos using the Cloudinary Go SDK.

Each project includes a set of Go files in its `lib` directory, with each file defining a single transformation:

* [Image transformation examples](https://github.com/cloudinary-devs/go-sdk-quickstart-image-examples/tree/main/src/lib)
* [Video transformation examples](https://github.com/cloudinary-devs/go-sdk-quickstart-video-examples/tree/main/lib)

The `main.go` file in each project imports these transformation functions and displays the transformed assets on a basic web page: 

> **TIP**:
>
> :title=Go to the code
> See the GitHub repos for the:

> * [Go SDK image transformations app](https://github.com/cloudinary-devs/go-sdk-quickstart-video-examples)

> * [Go SDK video transformations app](https://github.com/cloudinary-devs/go-sdk-quickstart-video-examples)

#### Setup instructions (after cloning from GitHub)

1. Open your terminal and navigate to your project directory.

2. Set your Cloudinary credentials as environment variables. Replace the placeholders with your actual Cloudinary credentials, which you can find in the [API Keys](https://console.cloudinary.com/app/settings/api-keys) page of the Console Settings.
   
    ```Terminal
    export CLOUD_NAME=your_cloud_name
    export API_KEY=your_api_key
    export API_SECRET=your_api_secret
    ```

3. In the terminal run these commands:
   
    ```Terminal
    go mod init go-sdk-quickstart-image-examples
    go mod tidy
    ```

    > **NOTE**: When running the video app, enter `go mod init go-sdk-quickstart-video-examples`.
   
4. Run your app:
   
    ```Terminal
    go run main.go
    ```

    The response should be:

    ```Terminal
    Listening on :8080...
    ```

5. Open your browser and go to:
   
    ```Terminal
    http://localhost:8080/
    ```

Go to the [image transformations](https://github.com/cloudinary-devs/go-sdk-quickstart-image-examples) and [video transformations](https://github.com/cloudinary-devs/go-sdk-quickstart-video-examples) GitHub repos to try it out:

Image transformations

Video transformations

> **READING**:
>
> * Learn more about [uploading images and videos](go_image_and_video_upload) using the Go SDK.    

> * See examples of powerful image and video transformations using, and see our [image transformations](image_transformations) and [video transformations](video_manipulation_and_delivery) docs. 

> * Check out Cloudinary's [asset management](dotnet_asset_administration) capabilities.

> * Stay tuned for updates by following the [Release Notes](programmable_media_release_notes) and the [Cloudinary Blog](https://cloudinary.com/blog).

