Beispiel #1
0
func Derp(img image.Image, opts *Options) [][]string {
	resizer := getResizer(
		img,
		opts.TargetWidth,
		opts.TargetHeight,
		opts.PixelRatio)
	resized := resizer.ResizeNearestNeighbor()
	colors := getColors(opts)
	txtImage := ascii.Convert(resized, colors)
	frame := txtImage.StringSlice()
	return [][]string{frame}
}
Beispiel #2
0
// for debugging
// prints the GIF union, then returns the frame pixmap
func testEncode(g *gif.GIF, idx, w, h int, pal []*ascii.TextColor) image.Image {
	// set up frame accumulator
	originalBounds := g.Image[0].Bounds()
	origSizer := resize.Resizer{g.Image[0], w, h, 0, 0}
	compiledImage := origSizer.ResizeNearestNeighbor()
	bg := image.NewUniform(color.RGBA{255, 255, 0, 255})

	compiledImage = image.NewRGBA(compiledImage.Bounds())
	frame := shrinkFrameToCorrectSize(g.Image[idx], w, h, &originalBounds)
	copyImageOver(compiledImage, bg)
	copyImageOver(compiledImage, frame)

	fmt.Fprintln(os.Stderr, ascii.Convert(frame, pal).String())
	fmt.Fprintln(os.Stderr, frame.Bounds())

	return compiledImage
}