TheZoraiz / ascii-image-converter

A cross-platform command-line tool to convert images into ascii art and print them on the console. Now supports braille art!
Apache License 2.0
2.05k stars 121 forks source link

Docker image #16

Open bnutzer opened 2 years ago

bnutzer commented 2 years ago

Hi,

ascii-image-converter just created the perfect startup banner for our spring boot application. Thanks a bunch!

As already noted, packaging is not trivial. A docker image for ascii-image-converter would make usage easier without the need for any local installation.

I am attaching a Dockerfile that created a well usable image for me. Dockerfile.ascii-image-converter.txt

(Usage: place in a working directory, such as an empty dir or the local git repo, execute docker build -t ascii-image-converter -f Dockerfile.ascii-image-converter.txt .. Usage of resulting image: docker run --rm -it ascii-image-converter <url>, or docker run -v $(pwd):/data --rm -it ascii-image-converter /data/<localfile>).

Would you be interested in providing an "official" image on docker hub?

If you prefer the file as a pull request, just give me a note.

TheZoraiz commented 2 years ago

Looks neat. However, I don't have a wealth of experience using, or maintaining docker images. A tad bit busy these days but I'll review and think about this soon.

vx-github commented 1 year ago

@bnutzer I did somewhat the same, but with a smaller (multi-stage) image build: https://hub.docker.com/r/dockvx/ascii-image-converter

@TheZoraiz I found out I need to supply --width when running from the image. Leaving --width out will result in a panic when converting a local file:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/TheZoraiz/ascii-image-converter/image_manipulation.ConvertToAsciiChars({0x0?, 0x872a00?, 0x884da0?}, 0x0?, 0x0?, 0x88?, 0x0?, 0x0?, {0x0, 0x0}, ...)
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/image_manipulation/ascii_conversions.go:55 +0xa51
github.com/TheZoraiz/ascii-image-converter/aic_package.pathIsImage({0x7ffc22446f1c, 0x14}, {0x0, 0x0}, 0x0, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...)
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/aic_package/convert_image.go:62 +0x3b4
github.com/TheZoraiz/ascii-image-converter/aic_package.Convert({0x7ffc22446f1c, 0x14}, {{0x0, 0x0, 0x0}, 0x0, 0x0, 0x0, {0x0, 0x0}, ...})
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/aic_package/convert_root.go:201 +0xc50
github.com/TheZoraiz/ascii-image-converter/cmd.printAscii({0x7ffc22446f1c?, 0x75a146?}, {{0x0, 0x0, 0x0}, 0x0, 0x0, 0x0, {0x0, 0x0}, ...})
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/cmd/root.go:112 +0x58
github.com/TheZoraiz/ascii-image-converter/cmd.glob..func1(0xd51aa0?, {0xc0000a1530?, 0x1, 0x1?})
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/cmd/root.go:102 +0x3bf
github.com/spf13/cobra.(*Command).execute(0xd51aa0, {0xc0000b2010, 0x1, 0x1})
    /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xd51aa0)
    /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x39d
github.com/spf13/cobra.(*Command).Execute(...)
    /go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/TheZoraiz/ascii-image-converter/cmd.Execute()
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/cmd/root.go:133 +0x25
main.main()
    /go/pkg/mod/github.com/!the!zoraiz/ascii-image-converter@v1.13.0/main.go:22 +0x17

This doesn't happen when converting an image from an URL, so this could be a bug when converting local files?