Coding the imagix library
In this section, we'll write the code for the image resizing and image statistics functionalities. Let's first look at the code structure.
The module structure of the imagix
library is summarized in Figure 4.4:
The imagix
library will consist of two modules, resize and stats, represented by resize.rs
and stats.rs
respectively. There are two enums
, SizeOption
and Mode
, for representing the variants for size option and mode respectively. The user will specify one of the variants of the SizeOption
enum
to indicate the desired output image size, and one of the variants of the Mode
enum
to indicate whether one or multiple images need to be resized. There is also struct Elapsed
for capturing elapsed time of the image resizing operation.
The resize
module has the process_resize_request()
public function, which is the main entry point into the imagix
library for resizing...