# town share

_being a way to share multimedia with each other that mimics rot_

sometimes, townies want to share images and videos with each other.

this leads to a set of behaviors:

- using a corporate photo album soft ware to create a public link (feels antithetical to town culture)
- uploading to a photo sharing site to get a link (there aren't a ton of these left, many are shady)
- SCPing a photo to town (clumsy when you just want to share from phone, uses disk space inefficiently)

though this is not a bleeding wound of a community issue, it is one that makes me itch. a kind of mosquito bite.

i do not wish to be in the business of just hosting people's massive photos. that sounds unfun and annoying.

however, i _do_ wish to be in the business of hosting artfully lossy versions of people's photos. the business grows even tastier if those photos rot -- one pixel at a time, perhaps -- until there's nothing left. disk usage should always converge on zero. the undifferentiated smear of a brown leafed forest floor. better yet: every photo leaves a unique stain of pixels. storage compact, just enough to say "there was a thing here. here's what is left."

## the flow

1. user has a picture they want to share with a persistent, easy to copy and paste url
2. user opens a webpage, https://share.tilde.town, which has an "upload image" form at the top
3. they select a style, one of:
  a. dithered
  b. heavily compressed
  c. 1 bit
  d. ascii art
4. they choose whether or not to secretify this upload
5. the image is uploaded; the bits are stored somewhere (disk or blob storage) and its initial checksum is saved as a seed value
6. the user is redirected to their photo

meanwhile, a cron job rots the photos on disk. an array of pixel values is computed based on the original checksum: these pixels are sacred and uncorruptible. N random cells are rotted (fewer for ascii art). fully rotted images are noted as done and ignored by the cron job.

## a bugaboo

i want to think through authentication. my first thought was that this would be fully public. sure, that's an option. but it will keep me up at night.

better that townies all have a secret unique to them they can print out while on server for storage in a cookie. that cookie lets them upload. it also generates galleries for them including the uploads not marked as secretified.

thus, https://share.tilde.town/~vilmibm will have my photos flowed on out.

## cli tool

town share has a corresponding CLI tool for use on or off the town. it reads the same secret used on the web site and uploads the image to the server.

```
$ town-share foo.jpg
flavor: 1. dithering 2. heavy compression 3. 1 bit 4. ascii art
include in web galley? Yn

file's done.

https://share.tilde.town/~vilmibm/abc123.gif
```

## future dreams

the big future dream is to handle other forms of media -- video and sound. but to start I am happy with just images.

## the questions

- what image format to use in storage? iirc the dithering tricks only work for gif so that's easy. ascii art is txt. maybe heavy compression can be jpg? 1 bit could be a bmp..?
- where to store files?
  - duh -- in people's home dirs. if they want to delete an image, remove it from the directory.
  - this has the side effect of letting people put arbitrary images into the directory; i think that's a feature not a bug.
- what format for image names?
  - initially i had the thought they should be date sorted. but, why! fuck that, just lexigraphically sort and let the filename be a random hash of some kind. something like: 8 digits, alphanumeric, dash in the middle, extension
- what sort of secret? i can just mimic whatever i do for invite codes.
- what state is required beyond the files? i want a notion of "done" for rotting. that could be a file size. ie, rot until a file is below a certain size. since the whole point of rotting (in addition to aesthetics/philosophy/lulz) is to reduce disk impact over time, file size should be the indication of whether further rot is required.
