<commit_before>* go-image2ascii

API service to Convert an Image to ASCII art

There is a command line version of the conversion tool and an http
service built with goswagger.

* Build

** Makefile available with a few options

*** make

Clean up, generate code, test, build, vet, and install http server in a simple way.

*** make help

Description of how to use the make cmds.

#+BEGIN_SRC
These 'make' targets are available.

  all                Clean, generate, test, build, vet, install
  clean              Removes all build output
  generate           Generates all code needed
  test               Run the unit tests
  build              Builds the binary
  vet                Runs govendor vet against proejct
  install            Installs the binary to /home/cp16net/gospace/bin
  tools              Installs tools needed to run
  release-base       Builds docker image for release
  build-image        Builds docker image for release
  publish-image      Publish csm docker image to registry
#+END_SRC


* Usage

#+BEGIN_SRC
go-image2ascii converts an image to ascii art.

Usage:
  go-image2ascii [command]

Available Commands:
  convert     Converts an image to acsii art
  help        Help about any command
  http        Run an http server

Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
  -h, --help            help for go-image2ascii

Use "go-image2ascii [command] --help" for more information about a command.
#+END_SRC

** convert cmd

go-image2ascii convert [-j] <path to file>

#+BEGIN_SRC
Converts an image to acsii art

Usage:
  go-image2ascii convert [full filepath to image] [flags]

Flags:
  -h, --help   help for convert
  -j, --json   output in json format

Global Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
#+END_SRC

** http cmd

#+BEGIN_SRC
This runs an http web server. (testing this out)

Usage:
  go-image2ascii http [flags]

Flags:
      --bind string   interface to which the server will bind (default "127.0.0.1")
  -h, --help          help for http
  -p, --port int      port on which the server will listen (default 8080)

Global Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
#+END_SRC

*** example requests

requires curl and jq (optional) installed.

#+BEGIN_SRC
curl -H "Content-Type: multipart/form-data" -X POST --form "uploadfile=@Golang.png" http://127.0.0.1:8080/upload
curl -H "Content-Type: multipart/form-data" -X POST --form "uploadfile=@Golang.png" http://127.0.0.1:8080/upload | jq '.'
curl -H "Content-Type: multipart/form-data" -X POST --form "uploadfile=@Golang.png" http://127.0.0.1:8080/upload | jq -r '.string'
#+END_SRC

* References

** main convert code

- https://gist.github.com/cdiener/10567484
- https://github.com/stdupp/goasciiart
- https://library.launchkit.io/on-the-fly-media-upload-processing-with-go-73995ffe10f3

** gopher images

- Source	http://golang.org/doc/gopher/
- Author	<NAME> http://reneefrench.blogspot.com

* Notes

** HTML Output

I expected to serve a simple html form to test via browser from "/"
and "/upload" but this didnt work so well because goswagger doesnt
natively support text/html content type output. I was able to serve it
via test/plain but the mimetype on the response isnt right to show the
html page that is delivered.

This seems like a trivial task but has proven a little more painful
than i'd thought.

Maybe this reference would help.
https://astaxie.gitbooks.io/build-web-application-with-golang/en/04.5.html

** Limits

Limit the size of the uploaded file to 5 mb.

** Validation

Also no initial validation of file types on http headers of the request.

** Image Conversion

Processes the file upload stream directly to the image decoding routine.

The ASCII charactors to represent an image is set to 16
currently. Ideally this could be changed by just using a different
charactor set for the ASCII constant value.

The resizing of the image is done by hard coding the width and using
it to keep the aspect ratio of the image's height the same.

* Testing

** Unit Tests

Code coverage of critical parts of the application are tested. Left
out any generated code test coverage because this code while core to
the execution and run of the application could change depending on the
version of swagger that you have installed for generation.

** Benchmarks

(NONE)

It would be nice to be able to run some simple benchmarking tests to
verify the speed of this routine against another proposed solution in
the future.<commit_msg>readme updates<commit_after>* go-image2ascii

API service to Convert an Image to ASCII art

There is a command line version of the conversion tool and an http
service built with goswagger.

Built and tested with `go version go1.8.1 linux/amd64`

* Build

** Makefile available with a few options

*** make

Clean up, generate code, test, build, vet, and install http server in a simple way.

*** make help

Description of how to use the make cmds.

#+BEGIN_SRC
These 'make' targets are available.

  all                Clean, generate, test, build, vet, install
  clean              Removes all build output
  generate           Generates all code needed
  test               Run the unit tests
  build              Builds the binary
  vet                Runs govendor vet against proejct
  install            Installs the binary to /home/cp16net/gospace/bin
  tools              Installs tools needed to run
  release-base       Builds docker image for release
  build-image        Builds docker image for release
  publish-image      Publish csm docker image to registry
#+END_SRC


* Usage

#+BEGIN_SRC
go-image2ascii converts an image to ascii art.

Usage:
  go-image2ascii [command]

Available Commands:
  convert     Converts an image to acsii art
  help        Help about any command
  http        Run an http server

Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
  -h, --help            help for go-image2ascii

Use "go-image2ascii [command] --help" for more information about a command.
#+END_SRC

** convert cmd

go-image2ascii convert [-j] <path to file>

#+BEGIN_SRC
Converts an image to acsii art

Usage:
  go-image2ascii convert [full filepath to image] [flags]

Flags:
  -h, --help   help for convert
  -j, --json   output in json format

Global Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
#+END_SRC

** http cmd

#+BEGIN_SRC
This runs an http web server. (testing this out)

Usage:
  go-image2ascii http [flags]

Flags:
      --bind string   interface to which the server will bind (default "127.0.0.1")
  -h, --help          help for http
  -p, --port int      port on which the server will listen (default 8080)

Global Flags:
      --config string   config file (default is $HOME/.go-image2ascii.yaml)
#+END_SRC

*** example requests

requires curl and jq (optional) installed.

#+BEGIN_SRC
curl -H "Content-Type: multipart/form-data" -X POST --form "uploadfile=@<EMAIL>" http://127.0.0.1:8080/upload
curl -H "Content-Type: multipart/form-data" -X POST --form "uploadfile=@<EMAIL>.png" http://127.0.0.1:8080/upload | jq '.'
curl -H "Content-Type: multipart/form-data" -X POST --form "<EMAIL>" http://127.0.0.1:8080/upload | jq -r '.string'
#+END_SRC

* References

** main convert code

- https://gist.github.com/cdiener/10567484
- https://github.com/stdupp/goasciiart
- https://library.launchkit.io/on-the-fly-media-upload-processing-with-go-73995ffe10f3

** gopher images

- Source	http://golang.org/doc/gopher/
- Author	<NAME> http://reneefrench.blogspot.com

* Notes

** HTML Output

I expected to serve a simple html form to test via browser from "/"
and "/upload" but this didnt work so well because goswagger doesnt
natively support text/html content type output. I was able to serve it
via test/plain but the mimetype on the response isnt right to show the
html page that is delivered.

This seems like a trivial task but has proven a little more painful
than i'd thought.

Maybe this reference would help.
https://astaxie.gitbooks.io/build-web-application-with-golang/en/04.5.html

** Limits

Limit the size of the uploaded file to 5 mb.

** Validation

Also no initial validation of file types on http headers of the request.

** Image Conversion

Processes the file upload stream directly to the image decoding routine.

The ASCII charactors to represent an image is set to 16
currently. Ideally this could be changed by just using a different
charactor set for the ASCII constant value.

The resizing of the image is done by hard coding the width and using
it to keep the aspect ratio of the image's height the same.

* Testing

** Unit

Code coverage of critical parts of the application are tested. Left
out any generated code test coverage because this code while core to
the execution and run of the application could change depending on the
version of swagger that you have installed for generation.

** Benchmark

(NONE)

It would be nice to be able to run some simple benchmarking tests to
verify the speed of this routine against another proposed solution in
the future.

** Integration

(NONE)

It would be nice to run this as a separate service and make sure that
the results from end to end are validated with some integration type
tests.

* License

[[LICENSE][Apache License]]
{'fraction_non_alphanumeric': 0.07648694908001712, 'fraction_numerical': 0.016581086863500214, 'mean_word_length': 3.1736607142857145, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6011787', 'n_tokens_mistral': 2915, 'n_tokens_neox': 2716, 'n_words': 1218}