designer

package module
v0.0.0-...-5c84cc4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 10 Imported by: 0

README

go-designer

A CLI and Go package to interact with Microsoft Designer to generate images.

Example

designer-cli "Flat vector illustration of a developer using a terminal"

Returns (after a few seconds):

INFO[0016] written 5031222530fccaa508c0a481694ae80f-0.jpg 
INFO[0016] written 5031222530fccaa508c0a481694ae80f-1.jpg 
INFO[0016] written 5031222530fccaa508c0a481694ae80f-2.jpg

The result output/5031222530fccaa508c0a481694ae80f-0.jpg should return something like this:

Flat vector illustration of a developer using a terminal

Installing

Requirements
  • Go 1.20+
Steps
go install github.com/denysvitali/go-designer/cmd/designer-cli
designer-cli -h
Getting the token
  1. Visit https://designer.microsoft.com/
  2. Retrieve the token (two options)
    1. Open the Developer Tools and check the response for the request to: https://login.microsoftonline.com/consumers/oauth2/v2.0/token Copy the value of access_token in your clipboard and keep it for later
    2. Generate an image and get the token from the Authorization: Bearer TOKEN header
  3. Store the token in the DESIGNER_TOKEN environment variable as follows:
    read -s -r DESIGNER_TOKEN
    # Paste your token and press ENTER
    export DESIGNER_TOKEN
    
Using the CLI

Pretty straight-forward:

designer-cli "Your prompt goes here"
Prompt suggestions
Generating Flat Vector Images
Flat vector illustration of ...

Example result: Flat vector illustration of a developer using a terminal

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveImages

func SaveImages(jsonResponse *Response, baseName string) ([]string, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(token string) Client

func (*Client) GenerateImages

func (c *Client) GenerateImages(prompt string) (*Response, error)

type CustomRoundTripper

type CustomRoundTripper struct {
}

func (CustomRoundTripper) RoundTrip

func (c CustomRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

type ImageUrlsThumbnails

type ImageUrlsThumbnails struct {
	ImageUrl      string `json:"ImageUrl"`
	ThumbnailData string `json:"ThumbnailData"`
}

type Response

type Response struct {
	B64Images          []string              `json:"b64_images"`
	ImageUrls          []string              `json:"image_urls"`
	ImageUrlsThumbnail []ImageUrlsThumbnails `json:"image_urls_thumbnail"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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