bbd

package module
v0.0.0-...-6b70915 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 3 Imported by: 0

README

Blurred Image Border

Package go.htdvisser.nl/bbd resizes an image and adds blurred image borders to make the image fit the target ratio.

GoDoc

Before (1728x1080):

before

After (1920x1080):

after

image source

Documentation

Overview

Package bbd renders blurred image borders

Index

Examples

Constants

This section is empty.

Variables

View Source
var Interpolation = resize.Bicubic

Interpolation algorithm to use

Functions

func Render

func Render(dst draw.Image, src image.Image, details uint)

Render the source image and a blurred background to the destination

Example
package main

import (
	"image"
	"image/jpeg"
	"os"

	"go.htdvisser.nl/bbd"
)

func main() {
	// Open the source file
	srcFile, err := os.Open("doc/src.jpg")
	if err != nil {
		panic(err)
	}
	defer srcFile.Close()

	// Read the image from the source file
	src, _, err := image.Decode(srcFile)
	if err != nil {
		panic(err)
	}

	// Create the destination image
	img := image.NewRGBA(image.Rect(0, 0, 1920, 1080))

	// Render
	bbd.Render(img, src, 3)

	// Open the destination file
	f, err := os.OpenFile("doc/dst.jpg", os.O_WRONLY|os.O_CREATE, 0644)
	if err != nil {
		panic(err)
	}
	defer func() {
		err = f.Close()
		if err != nil {
			panic(err)
		}
	}()
	err = jpeg.Encode(f, img, &jpeg.Options{
		Quality: 90,
	})
	if err != nil {
		panic(err)
	}
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL