imgconv

package module
v0.0.0-...-4a8e0ad Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 9 Imported by: 3

README

imgconv

A GoLang library for converting images using existing software on the user's machine.

As of now only supports png to svg, but I have plans to support all image types in the supported programs (currently ImageMagick, Inkscape and rsvg-convert).

API:

Convert
func Convert(data io.Reader, w int, h int, format string)

Convert takes a reader (image) as input, returning a reader of the converted data in the format supplied. If not successful, it will return the original image and an error.

ConvertWithAspect

ConvertWithAspect does the same thing as Convert, but takes only one dimension for size. The int represents the maximum length of the longer axis, while the shorter will be scaled proportionally.

func ConvertWithAspect(data io.Reader, maxRes int, format string) (io.Reader, error) {
ConvertFile
ConvertFile(src string, dest string, w int, h int, format string) error {

ConvertFile takes a filepath, destination filepath, width, height and destination image format as input, returning a filepath of the converted image. If not successful, the file remains unchanged and no file will be supplied at 'dest'.

ConvertFileWithAspect
func ConvertFileWithAspect(src string, dest string, maxRes int, format string) error {

ConvertFileWithAspect is a combination of ConvertWithAspect and ConvertFile.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(data io.Reader, w int, h int, format string) (io.Reader, error)

Convert takes a reader (image) as input, returning a reader of the converted data in the format requested. If not successful, it will return the original image and an error.

func ConvertFile

func ConvertFile(src string, dest string, w int, h int, format string) error

ConvertFile does the same thing as Convert, just directly to a file

func ConvertFileWithAspect

func ConvertFileWithAspect(src string, dest string, maxRes int, format string) error

Combination of ConvertFile and ConvertWithAspect

func ConvertWithAspect

func ConvertWithAspect(data io.Reader, maxRes int, format string) (io.Reader, error)

Does the same thing as Convert, but only uses one dimension as input, it keeps the aspect ratio, using the input value as the maximum width or height of the final image

func GetType

func GetType(data io.Reader) (string, error)

GetType returns the common file extension of the image presented

Types

This section is empty.

Jump to

Keyboard shortcuts

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