juroku

package module
Version: v0.0.0-...-f9d9e4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 12 Imported by: 0

README

Juroku

Juroku converts an image (PNG or JPG) into a Lua script that can be loaded as a ComputerCraft API to be used to draw on terminals and monitors.

Building and Running

  1. You have to be using gcc 8 or 7 (even older versions may work as well, just untested). Juroku will not build on gcc 9+. If you see errors like
# github.com/1lann/imagequant
kmeans.c: In function ‘kmeans_do_iteration’:
kmeans.c:90:13: error: ‘hist_size’ not specified in enclosing ‘parallel’
   90 |     #pragma omp parallel for if (hist_size > 3000) \
      |             ^~~
kmeans.c:90:13: error: enclosing ‘parallel’
kmeans.c:94:69: error: ‘achv’ not specified in enclosing ‘parallel’
   94 |         unsigned int match = nearest_search(n, &achv[j].acolor, achv[j].tmp.likely_colormap_index, &diff);
      |                                                                     ^
kmeans.c:90:13: error: enclosing ‘parallel’
   90 |     #pragma omp parallel for if (hist_size > 3000) \
      |             ^~~
kmeans.c:94:30: error: ‘n’ not specified in enclosing ‘parallel’
   94 |         unsigned int match = nearest_search(n, &achv[j].acolor, achv[j].tmp.likely_colormap_index, &diff);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kmeans.c:90:13: error: enclosing ‘parallel’
   90 |     #pragma omp parallel for if (hist_size > 3000) \
      |             ^~~
kmeans.c:98:9: error: ‘map’ not specified in enclosing ‘parallel’
   98 |         kmeans_update_color(achv[j].acolor, achv[j].perceptual_weight, map, match, omp_get_thread_num(), average_color);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kmeans.c:90:13: error: enclosing ‘parallel’
   90 |     #pragma omp parallel for if (hist_size > 3000) \
      |             ^~~

You are using the wrong version of gcc.

  1. A cgo security exception is required to allow the libimagequant to build:
export CGO_CFLAGS_ALLOW=.*
export CGO_LDFLAGS_ALLOW=.*
  1. go get -u github.com/tmpim/juroku/cmd/juroku (or if you want to specify a specific C compiler, you can do CC="gcc-8" go get ...)
  2. Find juroku in your $GOPATH/bin and run it.

TODO: Release pre-built binaries.

Usage:

Usage: juroku [options] input_image

Juroku converts an image (PNG or JPG) into a Lua script that can be
loaded as a ComputerCraft API to be used to draw on terminals and monitors.
Images are not automatically downscaled or cropped.

input_image must have a height that is a multiple of 3 in pixels,
and a width that is a multiple of 2 in pixels.

Options:
  -d float
    	set the amount of allowed dithering (0 = none, 1 = most) (default 0.2)
  -license
    	show GPLv3 licensing disclaimer
  -o string
    	set location of output script (default "image.lua")
  -p string
    	set location of output preview (will be PNG) (default "preview.png")
  -q int
    	set the processing speed/quality (1 = slowest, 10 = fastest) (default 1)

Disclaimer

Juroku when built contains libimagequant which is licensed under GPLv3. For more information and the source code of the relevant portions, see: https://github.com/1lann/imagequant.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChunkImage

func ChunkImage(img image.Image) (image.Image, error)

ChunkImage chunks an image following the ComputerCraft requirements of maximum of 2 colors per 2x3 chunk of pixels and returns it. It is assumed that the palette has already been reduced to 16 colors.

func GenerateCode

func GenerateCode(img image.Image) ([]byte, error)

GenerateCode generates the ComputerCraft code to render the given image that must have an underlying color type of color.RGBA and is assumed to have ChunkImage already called on it.

func GetPalette

func GetPalette(img image.Image) color.Palette

GetPalette returns the palette of the image.

func Quantize

func Quantize(ref, img image.Image, speed int, dither float64) (image.Image, error)

Quantize quantizes an image into a maximum of 16 colors with the given parameters.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL