Documentation
¶
Overview ¶
Package imaging validates uploaded image files with the framework's bounded container inspection. Import it as imagingvalidation alongside the imaging package. Pixels are never decoded and filenames/client MIME are not consulted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dimensions ¶
func Dimensions[F File](limits imaging.Limits, constraints validation.DimensionConstraints) validation.Rule[F]
Dimensions checks an uploaded image's displayed pixel size. Put FileMaxSize and FileContentTypes before it in Bail so cheap metadata rejects first.
func DimensionsWithEngine ¶
func DimensionsWithEngine[F File](engine *imaging.Engine, constraints validation.DimensionConstraints) validation.Rule[F]
DimensionsWithEngine validates uploads using the configured backend, including native formats when available. It borrows the engine without closing it.
Types ¶
type File ¶
type File interface {
validation.FileValue
// Open opens a seekable file reader that the caller must close.
Open(context.Context) (io.ReadSeekCloser, error)
}
File is captured upload metadata with a bounded reopenable reader. HTTP UploadedFile implements it.
type Measurer ¶
type Measurer[F File] struct { // contains filtered or unexported fields }
Measurer reads a captured file of at most Limits.InputBytes into memory and inspects its container with the portable inspector or a borrowed Engine. Larger, absent, unsupported or malformed files reject; read and open failures are execution failures. EXIF-style orientations that rotate by 90 degrees swap width and height, so constraints apply to the displayed image.
func NewEngineMeasurer ¶
NewEngineMeasurer uses an existing engine's backend, bounds and admission. The application retains ownership of the engine and must keep it open.
func NewMeasurer ¶
NewMeasurer creates an image measurer with the supplied inspection limits.