@@ -0,0 +1,3812 @@
+package ee.ttu.geocollection.endpoint.web;%0A%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.web.bind.annotation.GetMapping;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0Aimport javax.imageio.ImageIO;%0Aimport java.awt.*;%0Aimport java.awt.image.BufferedImage;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0A@RestController%0Apublic class ImageController %7B%0A%0A    private static final String DELIMITER = %22/%22;%0A    private static final String VAR = %22var%22;%0A    private static final String WWW = %22www%22;%0A    private static final String IMAGE = %22image%22;%0A    public static final String SPECIMEN = %22specimen%22;%0A%0A    @GetMapping(value = %22/img/%7BdbAcronym%7D/%7Bseries%7D/%7Bnumber%7D/%7BfileName%7D/%7Bwidth%7D%22, produces = MediaType.IMAGE_JPEG_VALUE)%0A    public byte%5B%5D retrieveImage(%0A            @PathVariable String dbAcronym,%0A            @PathVariable String series,%0A            @PathVariable String number,%0A            @PathVariable String fileName,%0A            @PathVariable Integer width) throws IOException %7B%0A        File imageFile = new File(%0A                DELIMITER + VAR + DELIMITER + WWW + DELIMITER%0A                        + dbAcronym + DELIMITER%0A                        + IMAGE + DELIMITER%0A                        + series + DELIMITER%0A                        + number + DELIMITER%0A                        + fileName);%0A        BufferedImage image = ImageIO.read(imageFile);%0A        Dimension resizedDimension = calculateNewDimension(new Dimension(image.getWidth(), image.getHeight()), width);%0A        BufferedImage resizedImage = resizeImage(image, resizedDimension);%0A%0A        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();%0A        ImageIO.write(resizedImage, %22jpg%22, outputStream);%0A        return outputStream.toByteArray();%0A    %7D%0A%0A    private Dimension calculateNewDimension(Dimension imgSize, Integer boundWidth) %7B%0A        int original_width = imgSize.width;%0A        int original_height = imgSize.height;%0A        int new_width = original_width;%0A        int new_height = original_height;%0A        // check if we need to scale width%0A        if (original_width %3E boundWidth) %7B%0A            //scale width to fit%0A            new_width = boundWidth;%0A            //scale height to maintain aspect ratio%0A            new_height = (new_width * original_height) / original_width;%0A        %7D%0A        return new Dimension(new_width, new_height);%0A    %7D%0A%0A    private BufferedImage resizeImage(Image originalImage, Dimension dimension) %7B%0A        int type = BufferedImage.TYPE_INT_ARGB;%0A        int height = (int) dimension.getHeight();%0A        int width = (int) dimension.getWidth();%0A%0A        BufferedImage resizedImage = new BufferedImage(width, height, type);%0A        Graphics2D g = resizedImage.createGraphics();%0A%0A        g.setComposite(AlphaComposite.Src);%0A        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);%0A        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);%0A        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);%0A%0A        g.drawImage(originalImage, 0, 0, width, height, null);%0A        g.dispose();%0A%0A        return resizedImage;%0A    %7D%0A%0A//    @GetMapping(value = %22/specimenImg/%7BdbAcronym%7D/%7BimagePath%7D%22, produces = MediaType.IMAGE_JPEG_VALUE)%0A//    public byte%5B%5D retrieveSpecimenImage(@PathVariable String dbAcronym, @PathVariable String imagePath) %7B%0A//        File imageFile = new File(%0A//                DELIMITER + VAR + DELIMITER + WWW + DELIMITER%0A//                        + dbAcronym + DELIMITER%0A//                        + IMAGE + DELIMITER%0A//                        + SPECIMEN + DELIMITER%0A//                        + imagePath);%0A//%0A//    %7D%0A%7D%0A

Implement image retrieval