### Install imgconv Package (Shell) Source: https://github.com/sunshineplan/imgconv/blob/main/README.md Provides the command to install the imgconv package using Go's module system. This command ensures that the latest version of the package is downloaded and made available for use in your Go projects. ```Shell go get -u github.com/sunshineplan/imgconv ``` -------------------------------- ### Resize Image (Go) Source: https://github.com/sunshineplan/imgconv/blob/main/README.md Demonstrates how to resize an image using the imgconv package. Resizing can be done by specifying a target width, height, or a percentage of the original size, while maintaining the aspect ratio. The `ResizeOption` struct is used to configure the resizing parameters. ```Go package main import ( "log" "github.com/sunshineplan/imgconv" ) func main() { // Open a test image. ssrc, err := imgconv.Open("testdata/video-001.png") if err != nil { log.Fatalf("failed to open image: %v", err) } // Resize the image to width = 200px preserving the aspect ratio. mark := imgconv.Resize(src, &imgconv.ResizeOption{Width: 200}) } ``` -------------------------------- ### Convert Image Format (Go) Source: https://github.com/sunshineplan/imgconv/blob/main/README.md Demonstrates converting an image to a different format, such as JPEG or TIFF, and writing it to an output. The `Write` function handles the format conversion based on the `FormatOption` provided, supporting various output formats. It requires an `io.Writer` for the destination. ```Go package main import ( "io" "log" "github.com/sunshineplan/imgconv" ) func main() { // Open a test image. src, err := imgconv.Open("testdata/video-001.png") if err != nil { log.Fatalf("failed to open image: %v", err) } // Resize the image to width = 200px preserving the aspect ratio. mark := imgconv.Resize(src, &imgconv.ResizeOption{Width: 200}) // Add random watermark set opacity = 128. dst := imgconv.Watermark(src, &imgconv.WatermarkOption{Mark: mark, Opacity: 128, Random: true}) // Write the resulting image as TIFF. if err := imgconv.Write(io.Discard, dst, &imgconv.FormatOption{Format: imgconv.TIFF}); err != nil { log.Fatalf("failed to write image: %v", err) } } ``` -------------------------------- ### Add Watermark (Go) Source: https://github.com/sunshineplan/imgconv/blob/main/README.md Shows how to add a watermark to an image. The `Watermark` function allows for setting a watermark image, its opacity, and its position. The watermark can be placed randomly or at a fixed position with an optional offset. ```Go package main import ( "log" "github.com/sunshineplan/imgconv" ) func main() { // Open a test image. src, err := imgconv.Open("testdata/video-001.png") if err != nil { log.Fatalf("failed to open image: %v", err) } // Resize the image to width = 200px preserving the aspect ratio. mark := imgconv.Resize(src, &imgconv.ResizeOption{Width: 200}) // Add random watermark set opacity = 128. dst := imgconv.Watermark(src, &imgconv.WatermarkOption{Mark: mark, Opacity: 128, Random: true}) } ``` -------------------------------- ### Split Image (Go) Source: https://github.com/sunshineplan/imgconv/blob/main/README.md Illustrates how to split an image into multiple parts either horizontally or vertically using the `Split` function. This function takes the source image, the number of parts, and the split mode (horizontal or vertical) as arguments. It returns a slice of images and an error if the operation fails. ```Go package main import ( "log" "github.com/sunshineplan/imgconv" ) func main() { // Open a test image. src, err := imgconv.Open("testdata/video-001.png") if err != nil { log.Fatalf("failed to open image: %v", err) } // Split the image into 3 parts horizontally. imgs, err := imgconv.Split(src, 3, imgconv.SplitHorizontalMode) if err != nil { log.Fatalf("failed to split image: %v", err) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.