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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.