Generating thumbnails for images

In this section, we will introduce a way to generate thumbnails for images of extension .jpg, jpeg, and .png. We will create a class called ThumbnailCreator to take care of the thumbnail creation. Figure 13.5 shows its relationship with its dependency, ImageProcessor, which is responsible for the actual image resizing and retrieving the image's actual size:

Figure 13.5: ThumbnailCreator diagram

The following is how the create() method of ThumbnailCreator looks:

...@Componentpublic class ThumbnailCreator {  ...  public void create(FileStorage fileStorage, TempFile tempImageFile) { Assert.isTrue(tempImageFile.getFile().exists(), ...

Get Building Applications with Spring 5 and Vue.js 2 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.