Giter VIP home page Giter VIP logo

fleep-go's Introduction

fleep

Go Report Card License

File format determination package for Go

Getting Started

fleep is a package that determines file format by file signature (also known as "magic number").

Installation

You can download the source using go get command:

go get github.com/floyernick/fleep-go

Usage

Main function GetInfo() determines file format. It takes byte sequence (>=128) as an argument and returns Info structure.

Info has the following fields:

  • Type ([]string) -> list of suitable file types
  • Extension ([]string) -> list of suitable file extensions
  • Mime ([]string) -> list of suitable file MIME types

Also Info has the following methods:

  • TypeMatches() -> checks if file type matches with given type as an argument
  • ExtensionMatches() -> checks if file extension matches with given extension as an argument
  • MimeMatches() -> checks if file MIME type matches with given MIME type as an argument

There is an example:

package main

import (
	"fleep"
	"fmt"
	"io/ioutil"
)

func main() {
	file, _ := ioutil.ReadFile("gopher.png")      // Reads PNG file
	info, _ := fleep.GetInfo(file)                // Gets file format
	fmt.Println(info.Type)                        // Prints [raster-image]
	fmt.Println(info.Extension)                   // Prints [png]
	fmt.Println(info.Mime)                        // Prints [image/png]
	fmt.Println(info.TypeMatches("raster-image")) // Prints true
	fmt.Println(info.ExtensionMatches("jpg"))     // Prints false
	fmt.Println(info.MimeMatches("image/png"))    // Prints true
}

Supported Formats

There is a list of supported formats (in alphabetical order):

Raster Image:

  • BMP
  • GIF
  • ICO
  • JP2
  • JPEG
  • PNG
  • PSD
  • TIFF
  • WEBP

Raw Image:

  • ARW
  • CR2
  • CRW
  • DNG
  • ERF
  • NEF
  • NRW
  • ORF
  • PEF
  • RAF
  • RAW
  • RW2
  • SRW
  • X3F

Vector Image:

  • AI
  • EPS

3D Image:

  • C4D
  • FBX
  • MA
  • MS3D
  • MTL
  • OBJ
  • PLY
  • WRL
  • X3D
  • XSI

Audio:

  • AAC
  • AC3
  • AIFF
  • AMR
  • AU
  • FLAC
  • M4A
  • MIDI
  • MKA
  • MP3
  • OGA
  • RA
  • VOC
  • WAV
  • WMA

Video:

  • 3G2
  • 3GP
  • ASF
  • AVI
  • FLV
  • M4V
  • MKV
  • MOV
  • MP4
  • MPG
  • OGV
  • SWF
  • VOB
  • WEBM
  • WMV

Document:

  • DOC
  • DOCX
  • EPUB
  • KEY
  • NUMBERS
  • ODP
  • ODS
  • ODT
  • PAGES
  • PDF
  • PPS
  • PPT
  • PPTX
  • RTF
  • XLS
  • XLSX
  • XML

Archive:

  • 7Z
  • DMG
  • GZ
  • ISO
  • RAR
  • TAR.Z
  • ZIP

Executable:

  • COM
  • EXE
  • JAR

Font:

  • OTF
  • TTF
  • WOFF
  • WOFF2

System:

  • CAB
  • CAT
  • DLL
  • DRV
  • REG
  • SDB
  • SYS

Database:

  • SQLITE

Contribute

We would be happy to receive your propositions of improvement! Read Contributing Guide for more details.

License

This project is licensed under the MIT License.

Authors

Mykyta Paliienko - GitHub profile

fleep-go's People

Contributors

ua-nick avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.