Documentation ¶
Overview ¶
Package size is for determining dimensions of media without decoding the entire file.
Example Usage:
giphy := "https://media1.giphy.com/media/l0ErxFClZX9L3bgBi/giphy.gif" res, err := http.Get(giphy) if err != nil { log.Fatal(err) } defer res.Body.Close() size, err := size.Parse(res.Body) if err != nil { log.Fatal(err) } jsonBytes, err := json.Marshal(size) if err != nil { log.Fatal(err) } fmt.Printf("%s", jsonBytes) // {"Width":480,"Height":270,"MediaType":"GIF"}
MIT License Copyright (c) 2020 Montana Flynn (https://montanaflynn.com)
Index ¶
Constants ¶
View Source
const ( // PNG media type PNG MediaType = "PNG" // GIF media type GIF = "GIF" // BMP media type BMP = "BMP" // JPEG media type JPEG = "JPEG" )
Variables ¶
View Source
var ( // ErrUnknownMediaType is when media is an unknown type ErrUnknownMediaType = fmt.Errorf("Unknown media type") // ErrUnsupportedSize is when media type doesn't implement size ErrUnsupportedSize = fmt.Errorf("Unsupported size") // ErrPNGMissingIHDR is when a png is missing the HDR header ErrPNGMissingIHDR = fmt.Errorf("Invalid png missing IHDR") // ErrBMPInvalidHeaderLength is when a bmp has invalid header length ErrBMPInvalidHeaderLength = fmt.Errorf("Invalid bmp header length") )
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.