| | |
| | | import de.uhilger.httpserver.base.handler.FileHandler; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * Der ImageFilter erzeugt verkleinerte Versionen einer Bilddatei |
| | |
| | | */ |
| | | public class ImageFilter extends Filter { |
| | | |
| | | private static final Logger logger = Logger.getLogger(ImageFilter.class.getName()); |
| | | |
| | | public static final String DESCRIPTION = "ImageFilter"; |
| | | |
| | | @Override |
| | | public void doFilter(HttpExchange exchange, Chain chain) throws IOException { |
| | | String uriStr = exchange.getRequestURI().toString(); |
| | | logger.fine(uriStr); |
| | | //logger.fine(uriStr); |
| | | //String ctxPath = exchange.getHttpContext().getPath(); |
| | | //String uriPath = exchange.getRequestURI().getPath(); |
| | | //logger.fine(uriPath); |
| | | //String fName = uriPath.substring(ctxPath.length()); |
| | | String fName = new HttpHelper().getFileName(exchange); |
| | | logger.fine(fName); |
| | | //logger.fine(fName); |
| | | if(uriStr.endsWith(ImageActor.JPG) || uriStr.endsWith(ImageActor.JPEG) || uriStr.endsWith(ImageActor.PNG)) { |
| | | File dir = new File(exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString()); |
| | | File imgfile = new File(dir, fName); |
| | |
| | | String fromName = fName.replace(ImageActor.B64, ""); |
| | | File fromfile = new File(dir, fromName); |
| | | //be.bildErzeugen(dir, fName, BildErzeuger.GR, 1200, imgfile); |
| | | logger.fine("from: " + fromfile.getAbsolutePath() + ", to: " + b64File.getAbsolutePath()); |
| | | //logger.fine("from: " + fromfile.getAbsolutePath() + ", to: " + b64File.getAbsolutePath()); |
| | | actor.b64Image(fromfile, b64File); |
| | | } |
| | | } |