GithubHelp home page GithubHelp logo

jackwilsdon / go-ppic Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 1.0 1.46 MB

A simple profile picture generator written in Go

Home Page: https://go-ppic.herokuapp.com

License: GNU Affero General Public License v3.0

Go 98.31% Dockerfile 1.69%
go image-generator

go-ppic's People

Contributors

jackwilsdon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

thejayhaykid

go-ppic's Issues

Add some logging at startup

Currently the server just starts quietly - it would be nice to know it has started up and provide a link to it in the console.

We should use net.Listen directly when starting the server, so that we can work out what port the server was allocated (when using port 0).

Add support for selecting a different color palette

We should support passing in either a custom palette (e.g. #FF0000,#00FF00) or a name of one from a pre-defined list of palettes (e.g. retro, inverted).

For example; /jackwilsdon?size=128&palette=retro

As an initial stage we could just support custom palettes and split out pre-defined palettes into a different issue.

Migrate from ZEIT Now

ZEIT Now 1.0 is being shut down on 20/08/2020, with deployments being stopped on 01/05/2020. Seeing as ZEIT Now 2.0 doesn't support continuously running servers, we'll need to migrate to a different platform entirely.

Possible alternatives:

  • Google App Engine
  • Heroku

Add support for margins on generated images

It'd be nice to have this as the default - maybe generating images with a "1 block" margin like so (1px border added to clarify margin);

Example image

This does raise the issue of "how do we scale images" now, as currently if you ask for a 512x512 image then we draw blocks of (512/8)x(512/8), which wouldn't be possible if a margin is added.


Alternatively we could discard the outer 1 block border like so, which does avoid the issue of scaling;

Example image #2

The issue now is that we've discarded over 40% of the source image by removing the surrounding 28 blocks! ๐Ÿ˜ฑ

Investigate supporting Go 1.11 again

After removing support for Go 1.11 in dab5093, it would be nice to get it back in some shape or form.

The error we were getting on 1.11 was as follows:

go build golang.org/x/sys/unix: module requires Go 1.12

Is there an older version of golang.org/x/sys/unix we can use that doesn't need Go 1.12?

Attach build artifacts to GitHub releases

It'd be nice to be have Travis attach compiled binaries to releases, so that they can be downloaded without having to be built by the end-user.

We should build for the following platforms;

GOOS GOARCH
darwin amd64
linux amd64
windows amd64

Add support for mirroring in the URL

Currently the Generate and GenerateImage methods accept arguments specifying whether or not the image should be mirrored on the X and Y axis, but it is hard-coded to mirror only on the X axis in the server request handler.

It'd be nice to have support for specifying how to mirror the image in the URL, much like how image size is specified;

https://ppic.now.sh/example.png?mirror=x,y

Or possibly;

https://ppic.now.sh/example.png?mirrorX=false&mirrorY

(where no value is true)

We should probably still default to mirroring on the X to preserve images as they are now.

Add support for returning SVGs

Not quite sure how we'd implement this yet - we'd probably need a whole separate GenerateSVG method, as GenerateImage returns an image.Image.

Add verbose mode

This mode should log all network requests, enabled using the -v flag.

Improve tests for image output

Currently we write tests as a massive array of expected pixels;

{
	path: "/jackwilsdon",
	size: 512,
	image: [8][8]color.Color{
		{jwPal.Foreground, jwPal.Background, jwPal.Foreground, jwPal.Background, jwPal.Background, jwPal.Foreground, jwPal.Background, jwPal.Foreground},
		{jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground},
		{jwPal.Foreground, jwPal.Background, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Background, jwPal.Foreground},
		{jwPal.Background, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Background},
		{jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background},
		{jwPal.Foreground, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Background, jwPal.Foreground},
		{jwPal.Foreground, jwPal.Background, jwPal.Foreground, jwPal.Background, jwPal.Background, jwPal.Foreground, jwPal.Background, jwPal.Foreground},
		{jwPal.Background, jwPal.Background, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Foreground, jwPal.Background, jwPal.Background},
	},
},

The issue with this is that it's a bit unwieldy! It would be nicer to be able to specify test cases like so;

{
	path: "/jackwilsdon",
	size: 512,
	palette: ppic.DefaultPalette,
	image: []string{
		"# #  # #",
		"########",
		"# #### #",
		" ###### ",
		"        ",
		"#      #",
		"# #  # #",
		"  ####  ",
	},
},

Where a # represents the foreground color of the palette and space the background.

Add support for CLI flags

ppicd can only be configured via environment variables at the moment โ€” it would be nice to be able to specify these options via command line flags too;

usage: ppicd [-dz] [-p port]
options:
    -d         enable pprof debug routes
    -z         enable gzip compression
    -p port    specify a port to run the server on (defaults to 3000)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.