in src/main/java/org/apache/sling/thumbnails/internal/TransformServlet.java [144:165]
private void performTransformation(SlingHttpServletRequest request, SlingHttpServletResponse response,
String transformationName, String renditionName, ResourceResolver serviceResolver)
throws IOException, ExecutionException {
Resource file = request.getResource();
String originalContentType = response.getContentType();
response.setContentType(OutputFileFormat.forRequest(request).getMimeType());
Optional<Transformation> transformationOp = transformationCache.getTransformation(serviceResolver,
transformationName);
if (!transformationOp.isPresent()) {
log.error("Unable to find transformation: {}", transformationName);
response.setContentType(originalContentType);
response.sendError(404, "Unable to find transformation: " + transformationName);
} else {
Transformation transformation = transformationOp.get();
log.debug("Transforming file...");
ByteArrayOutputStream baos = transform(request, response, transformation);
if (renditionSupport.supportsRenditions(file)) {
log.debug("Saving rendition...");
renditionSupport.setRendition(file, renditionName, new ByteArrayInputStream(baos.toByteArray()));
}
}
}