aspeq

package module
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: BSD-2-Clause Imports: 9 Imported by: 1

README

aspeq

aspeq finds the closest "standard" aspect ratio from an image file, or from relative or absolute dimensions (width and height)

defined ratios

  • tiktok (9:16)
  • instax (3:4)
  • square (1:1)
  • movietone (1.19:1)
  • four-thirds (4:3)
  • academy (1.375:1)
  • leica (3:2)
  • super16 (5:3)
  • sixteen-nine (16:9)
  • flat (1.85:1)
  • univisium (2:1)
  • cinemascope (2.35:1)
  • cinerama (2.59:1)
  • widelux (3:1)
  • polyvision (4:1)
  • circle-vision (12:1)

command line

$ aspeq *.jpeg
1.66.jpeg: super16
1.77.jpeg: sixteen-nine
2.35.jpeg: cinemascope

$ aspeq -x 1.66.jpeg
1.66.jpeg: 5:3

go

package main

import (
  "fmt"
  "blekksprut.net/aspeq"
)

func main() {
  ratio := aspeq.Match(320, 240)
  fmt.Println(ratio.Xy()) // prints "4:3"

  ar, err := aspeq.FromImage("1.66.jpeg") // a 40:24 image
  if err != nil {
    panic(err)
  }
  fmt.Println(ar.Name) // prints "super16"
}

Documentation

Index

Examples

Constants

View Source
const Version = "0.3.5"

Variables

View Source
var Ratios = [...]AspectRatio{
	{0.5625, "tiktok", 9, 16, Portrait},
	{0.75, "instax", 3, 4, Portrait},
	{1.0, "square", 1, 1, Square},
	{1.19, "movietone", 19, 16, Landscape},
	{1.333, "four-thirds", 4, 3, Landscape},
	{1.375, "academy", 4, 3, Landscape},
	{1.50, "leica", 3, 2, Landscape},
	{1.66, "super16", 5, 3, Landscape},
	{1.77, "sixteen-nine", 16, 9, Landscape},
	{1.85, "flat", 37, 20, Landscape},
	{2.0, "univisium", 2, 1, Landscape},
	{2.35, "cinemascope", 47, 20, Landscape},
	{2.59, "cinerama", 70, 27, Landscape},
	{3.0, "widelux", 3, 1, Landscape},
	{4.0, "polyvision", 4, 1, Landscape},
	{12.0, "circle-vision", 12, 1, Landscape},
}

Functions

This section is empty.

Types

type AspectRatio

type AspectRatio struct {
	Ratio       float64
	Name        string
	X           int64
	Y           int64
	Orientation Orientation
}

func FromImage

func FromImage(path string) (*AspectRatio, error)
Example
package main

import (
	"blekksprut.net/aspeq"
	"fmt"
)

func main() {
	ar, err := aspeq.FromImage("1.66.jpeg")
	if err != nil {
		panic(err)
	}
	fmt.Println(ar.Name)
}
Output:

super16

func Match added in v0.2.0

func Match(w int, h int) *AspectRatio
Example
package main

import (
	"blekksprut.net/aspeq"
	"fmt"
)

func main() {
	ar := aspeq.Match(1920, 1080)
	fmt.Println(ar.Name)
}
Output:

sixteen-nine

func (*AspectRatio) Xy

func (ar *AspectRatio) Xy() string

type Orientation

type Orientation int
const (
	Square Orientation = iota + 1
	Portrait
	Landscape
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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