Have to create placeholder images in Go project?

Overview of the "Sticket" - a Golang library, that generate placehold images with text 
07 August 2017   766
Go

Open source project developed by a team at Google and many contributors from the open source community.

All web developers one way or another have to deal with the layout. The task is to harmoniously arrange the content on the page (text, images, video, etc.), make it flexible, responsive, beautiful and appropriate design idea.

Placeholder images help all web developers to make their products pretty and suitable for any screensize. Let's learn how to generate placeholder images in Go project easily.

Sticker is a Go library, that  generate placeholder images with text.

Installation

Make sure you have a working Go environment.

To install sticker, simply run:

go get github.com/muesli/sticker

To execute it from source:

cd $GOPATH/src/github.com/muesli/sticker
go get -u -v
go build && go test -v

Example

gen, err := sticker.NewImageGenerator(sticker.Options{
    TTFPath:         "/usr/share/fonts/TTF/Roboto-Bold.ttf",
    MarginRatio:     0.2,
    Foreground:      color.RGBA{0x96, 0x96, 0x96, 0xff},
    Background:      color.RGBA{0xcc, 0xcc, 0xcc, 0xff},
    BackgroundImage: img,
})
img, err := gen.NewPlaceholder("Lorem ipsum!", 400, 200)
...
 

Sticker will automatically pick a suitable font size, so the text will always fit neatly inside the image.

If you supply a background image, it will automatically be cropped and scaled (while maintaining its original aspect ratio) to the desired output size.

Learn more and download Sticker from GitHub.

NGINX to Release Unit 1.3 Beta

Developers expanded the ability to run web applications in Python, PHP, Perl, Ruby and Go
16 July 2018   122

In open access, a beta version of the NGINX Unit 1.3 application server was released. Developers continued to expand the ability to run web applications in Python, PHP, Perl, Ruby and Go. The project code is written in C and is distributed under the Apache 2.0 license.

Features

Version 1.3 eliminates the problems with handling errors when installing HTTP connections.

Among other changes:

  • parameter max_body_size to limit the size of the body of the request;
  • new parameters for setting timeouts when setting up an HTTP connection:
         "settings": {
              "http": {
                  "header_read_timeout": 30,
                  "body_read_timeout": 30,
                  "send_timeout": 30,
                  "idle_timeout": 180,
                  "max_body_size": 8388608
              }
          },
  • automatic use of the Bundler where possible in the Ruby module;
  • http.Flusher interface in the module for the Go language;
  • The possibility of using characters in the UTF-8 encoding in the request headers.

The first version of the NGINX 1.1 application server was released in mid-April 2018. Under the control of NGINX Unit, several applications can be executed simultaneously in different programming languages, the startup parameters of which can be changed dynamically without the need to edit the configuration files and restart.