Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( Pattern.matches("png|jpg|jpeg", extension ) ) {
- String location = requestURL;
- //Open the stream from the location
- InputStream stream = new URL(location).openStream();
- //Create image stream
- Object obj = ImageIO.createImageInputStream(stream);
- //Setup the image reader
- ImageReader reader = ImageIO.getImageReaders(obj).next();
- //reader.setInput(obj, false);
- reader.setInput(obj);
- int w = reader.getWidth(0);
- stream.close();
- if( w > 480 ){
- String toReplace = requestURI.substring( requestURI.lastIndexOf("."), requestURI.length() );
- String newURI = requestURI.replace(toReplace, "");
- if( newURI.contains("/dotAsset/") ){
- newURI = newURI.replace("/dotAsset/", "");
- doLog("Replacing Image : ");
- doLog( "/contentAsset/image/" + newURI + "/fileAsset/filter/Resize/resize_w/480" );
- req.getRequestDispatcher( "/contentAsset/image/" + newURI + "/fileAsset/filter/Resize/resize_w/480" ).forward(req, res);
- }
- else{
- chain.doFilter(req, res);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement