Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Overview

Mosaic

This currently only operates on mapping individual pixels, I am working on writing this such that it maps multiple pixels to a single palette item, which is a work in progress.

Let's say you have a collection of images, and you want to put them together in a way that resembles any image you'd like. What this program does, is take as input, a folder of images (our palette), and an input image (what we are trying to recreate).

This basically goes through every item (image) in the palette and finds the average color for each item in the palette. After this process, we can then go through every pixel in our image, and figure out which item from our palette most resembles our pixel. Using this information, we can construct the mosaic by taking the pixels from items in our palette and writing them to a new image.

This can work with any set of images, it doesn't have to be emojis.

To compile:

cargo build --release

To use:

For prompts:

  • ./mosaic

For terminal argument input:

  • ./mosaic --help

command line args: ./mosaic -f Landscape-Color.png -p emoji -fs 256 -ps 16 -v 64.0

  • Specify file.png scaled to a max size of 256, using the palette "emoji" scaled to 16x16, with a "variance" of 1/64[^1][^2]

Pass in the extension for the file name!

How Do You Use Other Images?

1 Find a collection of images

2 Put the images into a named folder

  • In this repo, packaged for convenience, the mentioned collection is named emojis/

3 Put named folder under palettes/

Comments
  • panic: index out of range

    panic: index out of range

    OS: macOS Big Sur (11.5.1) GoKart Version: 0.1.0 Config: default Target: github.com/spiffe/spire

    Decided to give this a whirl against github.com/spiffe/spire but unfortunately hit a panic.

    $ go install github.com/praetorian-inc/gokart@latest
    go: downloading github.com/praetorian-inc/gokart v0.1.0
    go: downloading github.com/lithammer/dedent v1.1.0
    go: downloading github.com/owenrumney/go-sarif v1.0.11
    go: downloading github.com/segmentio/fasthash v1.0.3
    go: downloading golang.org/x/tools v0.1.2
    go: downloading github.com/zclconf/go-cty v1.8.4
    $ git clone https://github.com/spiffe/spire
    $ cd spire
    $ gokart scan .
    Using default analyzers config found at "~/.gokart/analyzers.yml".
    No existing analyzers.yml file found - writing default to ~/.gokart/analyzers.yml
    
    Revving engines VRMMM VRMMM
    3...2...1...Go!
    panic: runtime error: index out of range [0] with length 0
    
    goroutine 1 [running]:
    github.com/praetorian-inc/gokart/util.OutputFinding(0xc001acaf60, 0x2f, 0xc005a53e80, 0x7a, 0xc00205b680, 0x4a, 0x48, 0xc001acaf90, 0x28, 0x0, ...)
    	/redacted/go/pkg/mod/github.com/praetorian-inc/[email protected]/util/finding.go:54 +0x116f
    github.com/praetorian-inc/gokart/analyzers.Scan(0xc000074330, 0x1, 0x1)
    	/redacted/go/pkg/mod/github.com/praetorian-inc/[email protected]/analyzers/scan.go:128 +0x5bd
    github.com/praetorian-inc/gokart/cmd.glob..func1(0x16dcd00, 0xc000074330, 0x1, 0x1)
    	/redacted/go/pkg/mod/github.com/praetorian-inc/[email protected]/cmd/scan.go:53 +0x1ca
    github.com/spf13/cobra.(*Command).execute(0x16dcd00, 0xc000074300, 0x1, 0x1, 0x16dcd00, 0xc000074300)
    	/redacted/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x2c2
    github.com/spf13/cobra.(*Command).ExecuteC(0x16dca80, 0xc000000180, 0xc00016df78, 0x1006a25)
    	/redacted/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x375
    github.com/spf13/cobra.(*Command).Execute(...)
    	/redacted/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
    github.com/praetorian-inc/gokart/cmd.Execute(...)
    	/redacted/go/pkg/mod/github.com/praetorian-inc/[email protected]/cmd/root.go:61
    main.main()
    	/redacted/go/pkg/mod/github.com/praetorian-inc/[email protected]/main.go:38 +0x32
    
    opened by azdagron 6
  • Improved config mgmt and fixed out of bounds panic

    Improved config mgmt and fixed out of bounds panic

    Changed the way the config is loaded to use defined structs instead of nested maps of interface{}. Now, the config is loaded into a struct during initialization and the values are referenced by the struct fields as appropriate. This refrains from reading and parsing the config file twice (once when loading the default sources and again when loading any analyzers.

    Additionally, this change adds a length check to fix the panic shown in https://github.com/praetorian-inc/gokart/issues/2

    opened by jessesomerville 4
  • Implement support for non-nil exit code

    Implement support for non-nil exit code

    By passing the boolean argument --exitCode/-x to the scan cmd, a non-nil exit code will be returned on potential vulnerabilities findings.

    enhancement 
    opened by ourbjorn 3
  • Applying fix for issue #2 taken from @jessesomerville's PR

    Applying fix for issue #2 taken from @jessesomerville's PR

    • Fix taken from @jessesomerville's PR at https://github.com/praetorian-inc/gokart/pull/5/
    opened by michaelweber 1
  • Adding remoteModule flag to clone and scan remote module

    Adding remoteModule flag to clone and scan remote module

    Added -r or --remoteModule flag to support cloning a gomodule from a remote source and scanning.

    opened by bpsizemore 0
  • Changed panic to log.Fatal

    Changed panic to log.Fatal

    Made change from panic() to log.Fatal() to address https://github.com/praetorian-inc/gokart/issues/10

    opened by isp1r0 0
  • remove non-user-controllable input sources

    remove non-user-controllable input sources

    Removed several of the os.* sources that were producing FPs such as https://github.com/praetorian-inc/gokart/issues/12

    os.OpenFile os.Readdirnames os.Readdir os.FileMode os.FileInfo

    will not ever contain user-controllable data and thus can be safely removed.

    opened by isp1r0 0
  • Feature enhancement implementation for Issue #3 (Findings Output to File Flag)

    Feature enhancement implementation for Issue #3 (Findings Output to File Flag)

    • Adding the -o/--output flag for specifying a file path to write findings output to.
    • Small refactoring to consolidate all findings output generation/processing into a single function in scan.go
    • There is no default output file, it must be specified if this flag is used.
    • ONLY redirects finding output - any stdout output that is not finding associated will not be written.
    opened by michaelweber 0
  • Publish gokart in docker github packages

    Publish gokart in docker github packages

    do you think it makes sense to post a gokart docker image in github packages? I really like the idea of ​​this type of tool that I can use docker run praetorian-inc/gokart scan ...

    I even have something very similar here https://github.com/renanpalmeira/docker-protobufs/pkgs/container/protobuf

    on a daily basis I end up using it like this:

    docker run --rm \
        --name my-protos \
        -u $(id -u):$(id -u) \
        -v `pwd`:/code \
        ghcr.io/renanpalmeira/protobuf:latest \
            --proto_path=/code/protos \
            --go_out=plugins=grpc,paths=source_relative:/code/protos/gen \
            /code/protos/*.proto
    
    opened by renanpalmeira 0
  • Support to gokart in github actions marketplace

    Support to gokart in github actions marketplace

    hey hey do you have any plans to create a gokart action for us to use in github actions?

    I'm testing the gokart, I'm finding it really cool and I'd like to add it to github actions for an action very similar to gosec because of this the my question

    thanks 😊

    opened by renanpalmeira 0
  • Add SARIF format output to results file

    Add SARIF format output to results file

    Especially for the SARIF format.

    enhancement 
    opened by dwisiswant0 1
  • Adding -r flag to automatically clone and test remote go modules, along with functionality to test the Scan cmd

    Adding -r flag to automatically clone and test remote go modules, along with functionality to test the Scan cmd

    Added a new flag -r or --remoteModule which allows you to specify a remote module for analysis.

    gokart scan -r github.com/praetorian-inc/gokart
    

    Also added a new file gokart/cmd/scan_test.go which implements some very basic tests for the scan functionality. This should serve as a solid foundation as we add more features and modify the ability/way we specify modules to scan.

    opened by bpsizemore 0
  • Implement support for non-nil exit code

    Implement support for non-nil exit code

    Hi!

    To ease the use of this tool in automated systems such as CI/CD, and enable an optional failure mode on possible vulnerability findings, I suggest to implement a new boolean argument such as in #9 .

    With a non-nil exit code the CI/CD can stop pipelines and jobs easily when a potential vulnerability is found.

    enhancement 
    opened by ourbjorn 1
  • Any chance of supporting sonarqube?

    Any chance of supporting sonarqube?

    bulid gokart for sonarqube plugin

    enhancement 
    opened by jooeji 2
  • detect when external command running is vulnerable to option injection

    detect when external command running is vulnerable to option injection

    I noticed that gokart supports checking for command injection. Another related thing is when injecting command-line parameters allows you to inject parameters that get interpreted as options. Some options change the behaviour of commands in suboptimal ways, but some options to some commands can result in arbitrary code execution. The canonical paper about this type of attack is Back To The Future: Unix Wildcards Gone Wild by Leon Juranic of DefenseCode. It would be great if gokart could support detecting option injection.

    enhancement 
    opened by pabs3 0
  • False positive path traversal with unrelated untrusted input indicated

    False positive path traversal with unrelated untrusted input indicated

    Version 0.1.0.

    package foo
    
    import (
    	"io/ioutil"
    	"log"
    	"os"
    	"path/filepath"
    )
    
    func output(name string) error {
    	f, err := os.Open(name)
    	if err != nil {
    		return err
    	}
    	f.Write([]byte("foo"))
    	defer f.Close()
    
    	g, err := os.OpenFile("foo", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
    	if err != nil {
    		return err
    	}
    	g.Write([]byte("foo"))
    	return g.Close()
    }
    
    func Foo() (err error) {
    	tmpdir, err := ioutil.TempDir("", "foo")
    	if err != nil {
    		return err
    	}
    	defer func() {
    		if rerr := os.RemoveAll(tmpdir); rerr != nil {
    			log.Println(err)
    			err = rerr
    			return
    		}
    	}()
    
    	filename := filepath.Join(tmpdir, "foo.tmp")
    
    	return output(filename)
    }
    
    

    gives output

    $ gokart scan
    Using default analyzers config found at "~/.gokart/analyzers.yml".
    
    Revving engines VRMMM VRMMM
    3...2...1...Go!
    
    (Path Traversal) Danger: possible path traversal injection detected
    
    /home/stevie/gokart/foo.go:11
    Vulnerable Function: [ output(...) error ]
          10:	func output(name string) error {
        > 11:		f, err := os.Open(name)
          12:		if err != nil {
    
    /home/stevie/gokart/foo.go:18
    Source of Untrusted Input: [ output(...) error ]
          17:	
        > 18:		g, err := os.OpenFile("foo", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
          19:		if err != nil {
    ------------------------------------------------------------------------------
    
    Race Complete! Analysis took 146.430242ms and 63 Go files were scanned (including imported packages)
    GoKart found 1 potentially vulnerable functions
    
    

    Clearly, the line flagged as untrusted input is unrelated to name. If I remove the defer statement from Foo, no path traversal issue is detected.

    bug 
    opened by stevenjohnstone 1
  • Comparism with CodeQL

    Comparism with CodeQL

    Would it be possible to compare gokart with CodeQL, at least on some ballpark figure? For instance, can gokart detect problems with int conversions between different sizes, et cetera? For instance, CodeQL is very helpful at catching such things.

    And finally, the obvious question: does gokart detect race conditions?

    documentation 
    opened by TheDiveO 4
  • panic: err: go command required

    panic: err: go command required

    If go is not installed scan panics. Not a usual scenario.

    alexandre@localhost:~> gokart scan
    Using default analyzers config found at "~/.gokart/analyzers.yml".
    No existing analyzers.yml file found - writing default to ~/.gokart/analyzers.yml
    
    Revving engines VRMMM VRMMM
    3...2...1...Go!
    panic: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr: 
    
    goroutine 1 [running]:
    github.com/praetorian-inc/gokart/analyzers.Scan(0xc000035f80, 0x1, 0x1)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/analyzers/scan.go:97 +0x135f
    github.com/praetorian-inc/gokart/cmd.glob..func1(0x55a77c40cc20, 0xc000035f80, 0x1, 0x1)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/cmd/scan.go:53 +0x1ca
    github.com/spf13/cobra.(*Command).execute(0x55a77c40cc20, 0x55a77c43fa00, 0x0, 0x0, 0x55a77c40cc20, 0x55a77c43fa00)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:860 +0x2c2
    github.com/spf13/cobra.(*Command).ExecuteC(0x55a77c40c9a0, 0xc000000180, 0xc00013bf78, 0x55a77bb9efc5)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:974 +0x375
    github.com/spf13/cobra.(*Command).Execute(...)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/vendor/github.com/spf13/cobra/command.go:902
    github.com/praetorian-inc/gokart/cmd.Execute(...)
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/cmd/root.go:61
    main.main()
    	/home/abuild/rpmbuild/BUILD/gokart-0.1.0/main.go:38 +0x34
    

    Perhaps log.Fatal would make more sense in here as the analysis failed for some reason, I don't think anyone is going to recover from here.

    bug 
    opened by alexandrevicenzi 2
Owner
Jacob
I like image processing, I've been getting into the gradient domain lately! I like to use Rust or python :)
Jacob
Automated image compression for efficiently distributing images on the web.

Imager Apparently this project made it into the GitHub Archive Program. About Imager is a tool for automated image compression, and can competitively

Imager IO 487 Dec 25, 2022
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

Harrison Burt 242 Dec 22, 2022
Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

3top1a 4 Apr 9, 2022
Encoding and decoding images in Rust

Image Maintainers: @HeroicKatora, @fintelia How to contribute An Image Processing Library This crate provides basic image processing functions and met

image-rs 3.5k Jan 9, 2023
Encoding and decoding images in Rust

Image Maintainers: @HeroicKatora, @fintelia How to contribute An Image Processing Library This crate provides basic image processing functions and met

image-rs 3.5k Jan 2, 2023
CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console)

CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console). Supports most standard image formats, and some video formats.

Michael 30 Jan 1, 2023
A Rust library for calculating perceptual hash values of images

img_hash Now builds on stable Rust! (But needs nightly to bench.) A library for getting perceptual hash values of images. Thanks to Dr. Neal Krawetz f

Austin Bonander 264 Dec 9, 2022
Zero dependency images (of chaos) in Rust

bifurcate-rs Zero dependency images (of chaos) in Rust To run: time cargo run --release > img.pgm To convert from PGM to PNG using Image Magick: conve

Stephen Merity 32 Nov 17, 2021
Converts images into textual line art.

img2utf Transform images to textual line art! Images require pre-processing to come out nice. It's expected that users will do the following: Apply ga

Lee 149 Dec 10, 2022
Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Phil Spindler 3 Nov 2, 2021
Fetch original quality URLs for images posted to a Twitter account

twitter-images Fetches the last tweets of a given account, then prints original quality URLs for all image tweets. Useful for archiving image content

Harsh Shandilya 6 Dec 23, 2022
Simple CLI program to generate zoomable tiled images

zoomtiler Simple CLI program to generate deepzoom zoomable tiled images. The input can either be a single image or multiple images of the same height,

Matthieu Pizenberg 3 Mar 14, 2022
Signed distance field font and image command line tool based on OpenCL.

SDFTool Signed distance field font and image command line tool based on OpenCL. Build Windows Run cargo build --release in Visual Studio developer x64

弦语蝶梦 7 Oct 16, 2022
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

EmojiPix This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art vers

Michael Milton 22 Dec 6, 2022
Rust library to get image size and format without loading/decoding

imageinfo-rs Rust library to get image size and format without loading/decoding. The imageinfo don't get image format by file ext name, but infer by f

xiaozhuai, Weihang Ding 47 Dec 30, 2022
Simple image metadata scrubber. Will remove EXIF, XMP and IPTC metadata.

Simple image metadata scrubber. Will remove EXIF, XMP and IPTC metadata.

Jae Lo Presti 12 Nov 29, 2022
Image processing proxy and API, created to allow faster media delivery for the Holaplex storefront.

Description imgopt is an image processing proxy with a very simple API, created to download and dynamically scaledown, convert, and cache different me

Holaplex 5 Nov 3, 2022
Fastest image quadtree stylization implementation to date, capable of hundreds of fps and avoiding ugly non-squares.

Quadim Fastest image quadtree stylization implementation to date, capable of hundreds of fps and avoiding ugly non-squares. 简体中文 如果你是从B站来的…… “Listen t

K--A______ 13 May 11, 2023
Image processing operations

imageproc An image processing library, based on the image library. There may initially be overlap between the functions in this library and those in i

image-rs 512 Jan 8, 2023