spring-framework / org.springframework.http.converter / BufferedImageHttpMessageConverter

BufferedImageHttpMessageConverter

open class BufferedImageHttpMessageConverter : HttpMessageConverter<BufferedImage>

Implementation of HttpMessageConverter that can read and write BufferedImage.

By default, this converter can read all media types that are supported by the registered image readers, and writes using the media type of the first available registered image writer. The latter can be overridden by setting the defaultContentType property.

If the cacheDir property is set, this converter will cache image data.

The #process(ImageReadParam) and #process(ImageWriteParam) template methods allow subclasses to override Image I/O parameters.

Author
Arjen Poutsma

Since
3.0

Constructors

<init>

BufferedImageHttpMessageConverter()

Functions

canRead

open fun canRead(clazz: Class<*>, mediaType: MediaType): Boolean

canWrite

open fun canWrite(clazz: Class<*>, mediaType: MediaType): Boolean

getDefaultContentType

open fun getDefaultContentType(): MediaType

Returns the default Content-Type to be used for writing. Called when #write is invoked without a specified content type parameter.

getSupportedMediaTypes

open fun getSupportedMediaTypes(): MutableList<MediaType>

read

open fun read(clazz: Class<out BufferedImage>, inputMessage: HttpInputMessage): BufferedImage

setCacheDir

open fun setCacheDir(cacheDir: File): Unit

Sets the cache directory. If this property is set to an existing directory, this converter will cache image data.

setDefaultContentType

open fun setDefaultContentType(defaultContentType: MediaType): Unit

Sets the default Content-Type to be used for writing.

write

open fun write(image: BufferedImage, contentType: MediaType, outputMessage: HttpOutputMessage): Unit