code: @RequestMapping(value = "/customImage/{width}/{height}/**", method = RequestMethod.GET)
      public ResponseEntity<InputStreamResource> getCustomImage(WebRequest request, HttpServletRequest servletRequest,
                                                                @PathVariable(value = "width") String width, @PathVariable(value = "height") String height) throws IOException {
          if (!allowCustomImageSizes) {
              LOG.debug("Request for custom image was made despite allowCustomImageSizes being false.");
              throw new ResourceNotFoundException();
          }
          String path = extractPathFromPattern(servletRequest);
          LOG.debug("getCustomImage(width={}, height={}, path={})", width, height, path);
          try {
              int widthInt = Integer.parseInt(width);
              int heightInt = Integer.parseInt(height);
              if (widthInt <= 0 || heightInt <= 0) {
                  LOG.debug("Won't try to scale an image do negative dimensions...", path);
                  throw new ResourceNotFoundException();
              }
              GalleryFile galleryFile = galleryService.getImage(path, widthInt, heightInt);
              return returnResource(request, galleryFile);
          } catch (FileNotFoundException fnfe) {
              LOG.warn("Could not find resource {}", path);
              throw new ResourceNotFoundException();
          } catch (NotAllowedException nae) {
              LOG.warn("User was not allowed to access resource {}", path);
              throw new ResourceNotFoundException();
          } catch (NumberFormatException nfe) {
              LOG.warn("Could not parse image dimensions {}", path);
              throw new ResourceNotFoundException();
          } catch (IOException ioe) {
              LOG.error("Error when calling getImage", ioe);
              throw ioe;
          }
      }
docs: Requests an image of a custom size. This method will return the image
  only if {@link #allowCustomImageSizes} is set to true.
  
  @param request
  Spring request
  @param servletRequest
  Servlet request
  @param width
  Width in pixels
  @param height
  Height in pixels
  
  @return The image as a stream with the appropriate response headers set
  or a not-modified response, (see
  {@link #returnResource(WebRequest, GalleryFile)}).
  @throws IOException
  Sub-types of this exception are thrown for different
  scenarios, and the {@link IOException} itself for generic
  errors.