Class ImageCompressor

java.lang.Object
com.markvarga21.studentmanager.util.ImageCompressor

public final class ImageCompressor extends Object
A class which is used to compress images.
  • Field Details

    • SCALE_DECREASE_STEP

      public static final float SCALE_DECREASE_STEP
      The scale of which the image is decreased in each step.
      See Also:
    • DEFAULT_SIZE_LIMIT

      public static final int DEFAULT_SIZE_LIMIT
      The maximum file size accepted by the database in bytes.
      See Also:
  • Method Details

    • toByteArray

      @Generated public static byte[] toByteArray(BufferedImage bi, String format) throws IOException
      Converts the given image to a byte array.
      Parameters:
      bi - The image to be converted.
      format - The format of the image.
      Returns:
      The byte array of the image.
      Throws:
      IOException - If the image cannot be written.
    • compressImage

      public static byte[] compressImage(org.springframework.web.multipart.MultipartFile image)
      Compresses the given image.
      Parameters:
      image - The image to compress.
      Returns:
      The compressed image.