jackwilsdon / go-ppic Goto Github PK
View Code? Open in Web Editor NEWA simple profile picture generator written in Go
Home Page: https://go-ppic.herokuapp.com
License: GNU Affero General Public License v3.0
A simple profile picture generator written in Go
Home Page: https://go-ppic.herokuapp.com
License: GNU Affero General Public License v3.0
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
).
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.
PNG | JPG | GIF |
---|---|---|
It looks like this is probably JPG compression related - we set the quality to as low as possible:
Line 48 in 7c7d8b4
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:
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);
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;
The issue now is that we've discarded over 40% of the source image by removing the surrounding 28 blocks! ๐ฑ
This should be done after Travis has run it's tests, and can be done at the same time as #9.
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?
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 |
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.
Not quite sure how we'd implement this yet - we'd probably need a whole separate GenerateSVG
method, as GenerateImage
returns an image.Image
.
This mode should log all network requests, enabled using the -v
flag.
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.
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)
It'd be nice to move away from Travis and instead switch to using GitHub Actions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.