Mercurial > hg > digilib-old
comparison servlet/src/digilib/servlet/Scaler.java @ 352:5ded9e06cd57
Servlet version 1.5.9b
- added mo=png option to enforce PNG output
- set higher JPEG quality for mo=q2 (only ImageLoaderDocuImage)
| author | robcast |
|---|---|
| date | Wed, 14 Sep 2005 21:59:07 +0200 |
| parents | 269d1028dfb7 |
| children | 25095f85ba7c |
comparison
equal
deleted
inserted
replaced
| 351:269d1028dfb7 | 352:5ded9e06cd57 |
|---|---|
| 57 public class Scaler extends HttpServlet { | 57 public class Scaler extends HttpServlet { |
| 58 | 58 |
| 59 private static final long serialVersionUID = -325080527268912852L; | 59 private static final long serialVersionUID = -325080527268912852L; |
| 60 | 60 |
| 61 /** digilib servlet version (for all components) */ | 61 /** digilib servlet version (for all components) */ |
| 62 public static final String dlVersion = "1.5.8b"; | 62 public static final String dlVersion = "1.5.9b"; |
| 63 | 63 |
| 64 /** logger for accounting requests */ | 64 /** logger for accounting requests */ |
| 65 private static Logger accountlog = Logger.getLogger("account.request"); | 65 private static Logger accountlog = Logger.getLogger("account.request"); |
| 66 | 66 |
| 67 /** gengeral logger for this class */ | 67 /** gengeral logger for this class */ |
| 229 boolean sendFile = false; | 229 boolean sendFile = false; |
| 230 // use low resolution images only | 230 // use low resolution images only |
| 231 boolean loresOnly = false; | 231 boolean loresOnly = false; |
| 232 // use hires images only | 232 // use hires images only |
| 233 boolean hiresOnly = false; | 233 boolean hiresOnly = false; |
| 234 // send the image always as JPEG | 234 // send the image always as a specific type (e.g. JPEG or PNG) |
| 235 boolean forceJPEG = false; | 235 int forceType = ImageOps.TYPE_AUTO; |
| 236 // interpolation to use for scaling | 236 // interpolation to use for scaling |
| 237 int scaleQual = defaultQuality; | 237 int scaleQual = defaultQuality; |
| 238 // send html error message (or image file) | 238 // send html error message (or image file) |
| 239 boolean errorMsgHtml = false; | 239 boolean errorMsgHtml = false; |
| 240 // mirror the image | 240 // mirror the image |
| 341 } else if (dlRequest.hasOption("mo", "q2")) { | 341 } else if (dlRequest.hasOption("mo", "q2")) { |
| 342 scaleQual = 2; | 342 scaleQual = 2; |
| 343 } | 343 } |
| 344 // operation mode: "jpg": always use JPEG | 344 // operation mode: "jpg": always use JPEG |
| 345 if (dlRequest.hasOption("mo", "jpg")) { | 345 if (dlRequest.hasOption("mo", "jpg")) { |
| 346 forceJPEG = true; | 346 forceType = ImageOps.TYPE_JPEG; |
| 347 } | |
| 348 // operation mode: "png": always use PNG | |
| 349 if (dlRequest.hasOption("mo", "png")) { | |
| 350 forceType = ImageOps.TYPE_PNG; | |
| 347 } | 351 } |
| 348 | 352 |
| 349 // check with the maximum allowed size (if set) | 353 // check with the maximum allowed size (if set) |
| 350 int maxImgSize = dlConfig.getAsInt("max-image-size"); | 354 int maxImgSize = dlConfig.getAsInt("max-image-size"); |
| 351 if (maxImgSize > 0) { | 355 if (maxImgSize > 0) { |
| 634 | 638 |
| 635 DigilibWorker job = new DigilibImageWorker(dlConfig, response, | 639 DigilibWorker job = new DigilibImageWorker(dlConfig, response, |
| 636 mimeType, scaleQual, dlRequest, paramROT, paramCONT, | 640 mimeType, scaleQual, dlRequest, paramROT, paramCONT, |
| 637 paramBRGT, paramRGBM, paramRGBA, fileToLoad, scaleXY, | 641 paramBRGT, paramRGBM, paramRGBA, fileToLoad, scaleXY, |
| 638 outerUserImgArea, innerUserImgArea, minSubsample, | 642 outerUserImgArea, innerUserImgArea, minSubsample, |
| 639 wholeRotArea, forceJPEG); | 643 wholeRotArea, forceType); |
| 640 | 644 |
| 641 job.run(); | 645 job.run(); |
| 642 if (job.hasError()) { | 646 if (job.hasError()) { |
| 643 throw new ImageOpException(job.getError().toString()); | 647 throw new ImageOpException(job.getError().toString()); |
| 644 } | 648 } |
