Mercurial > hg > digilib-old
changeset 353:25095f85ba7c
Servlet version 1.5.9c
- (hopefully) fixed problem with digilib 1.5.9b stopping after a day...
author | robcast |
---|---|
date | Tue, 27 Sep 2005 19:37:28 +0200 |
parents | 5ded9e06cd57 |
children | 7958035abec1 |
files | servlet/src/digilib/image/ImageLoaderDocuImage.java servlet/src/digilib/servlet/Scaler.java |
diffstat | 2 files changed, 11 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Wed Sep 14 21:59:07 2005 +0200 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Sep 27 19:37:28 2005 +0200 @@ -193,10 +193,11 @@ public void writeImage(String mt, OutputStream ostream) throws FileOpException { logger.debug("writeImage"); + // setup output + ImageWriter writer = null; + ImageOutputStream imgout = null; try { - // setup output - ImageWriter writer = null; - ImageOutputStream imgout = ImageIO.createImageOutputStream(ostream); + imgout = ImageIO.createImageOutputStream(ostream); if (mt == "image/jpeg") { /* * JPEG doesn't do transparency so we have to convert any RGBA @@ -221,13 +222,7 @@ ImageWriteParam param = writer.getDefaultWriteParam(); if (quality > 1) { // change JPEG compression quality - if (param.getCompressionMode() != ImageWriteParam.MODE_EXPLICIT) { - // work around problem with J2RE 1.4 JPEG writer - logger.debug("creating new ImageWriteParam"); - param = new CompressibleJPEGImageWriteParam(param - .getLocale()); - param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); - } + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); logger.debug("JPEG qual before: " + Float.toString(param.getCompressionQuality())); param.setCompressionQuality(0.9f); @@ -255,6 +250,11 @@ } catch (IOException e) { throw new FileOpException("Error writing image."); + } finally { + // clean up + if (writer != null) { + writer.dispose(); + } } } @@ -506,25 +506,4 @@ img = null; } - /** - * Modified JPEGImageWriteParam that accepts a compression quality to work - * around problem with J2RE 1.4. - * - * @author casties - * - */ - public class CompressibleJPEGImageWriteParam extends JPEGImageWriteParam { - - public CompressibleJPEGImageWriteParam(Locale arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - public void setCompressionQuality(float quality) { - if (quality < 0.0F || quality > 1.0F) { - throw new IllegalArgumentException("Quality out-of-bounds!"); - } - this.compressionQuality = quality; - } - } }
--- a/servlet/src/digilib/servlet/Scaler.java Wed Sep 14 21:59:07 2005 +0200 +++ b/servlet/src/digilib/servlet/Scaler.java Tue Sep 27 19:37:28 2005 +0200 @@ -59,7 +59,7 @@ private static final long serialVersionUID = -325080527268912852L; /** digilib servlet version (for all components) */ - public static final String dlVersion = "1.5.9b"; + public static final String dlVersion = "1.5.9c"; /** logger for accounting requests */ private static Logger accountlog = Logger.getLogger("account.request");