".webp": WEBP,
}
- imageFormatsBySubType = map[string]Format{
+ // These are the image types we can process.
+ processableImageSubTypes = map[string]Format{
media.Builtin.JPEGType.SubType: JPEG,
media.Builtin.PNGType.SubType: PNG,
media.Builtin.TIFFType.SubType: TIFF,
}
func ImageFormatFromMediaSubType(sub string) (Format, bool) {
- f, found := imageFormatsBySubType[sub]
+ f, found := processableImageSubTypes[sub]
return f, found
}
// IsImage reports whether the given resource is an image that can be processed.
func IsImage(v any) bool {
- r, ok := v.(*resourceAdapter)
- if ok {
- _, ok := r.target.(images.ImageResourceOps)
- return ok
+ r, ok := v.(resource.Resource)
+ if !ok {
+ return false
}
- return false
+ mt := r.MediaType()
+ if mt.MainType != "image" {
+ return false
+ }
+ _, isImage := images.ImageFormatFromMediaSubType(mt.SubType)
+ return isImage
}
func (r *resourceAdapter) publish() {