Skip to content

Commit

Permalink
feat(lib/printiceland): Add PrintRadomIcelandPhoto method
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Nov 30, 2023
1 parent 180394d commit a652fce
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/printiceland/printiceland.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package printiceland

import (
"bytes"
"fmt"
"image"
_ "image/jpeg"
"log"
"math/rand"

"github.com/ondrejsika/go-iceland"
"github.com/qeesung/image2ascii/convert"
)

func PrintRadomIcelandPhoto() {
images := []*[]byte{
&iceland.ICELAND_SUNSET_2022,
&iceland.ICELAND_LAVA_FIELD_2022,
&iceland.ICELAND_RIVER_AT_POOL_2022,
&iceland.ICELAND_ICE_2018,
}
randomIndex := rand.Intn(len(images))
randomImage := images[randomIndex]

img, _, err := image.Decode(bytes.NewReader(*randomImage))
if err != nil {
log.Fatalln(err)
}
converter := convert.NewImageConverter()
fmt.Print(converter.Image2ASCIIString(img, &convert.DefaultOptions))
}

0 comments on commit a652fce

Please sign in to comment.