# HG changeset patch # User robcast # Date 1292834354 -3600 # Node ID 8beefd1142b28ca9b2433205e7eea82a517bb215 # Parent 4c51d71aef132cfea4fed0a21e82268414051899 more cleanup diff -r 4c51d71aef13 -r 8beefd1142b2 servlet/src/digilib/image/ImageJobDescription.java --- a/servlet/src/digilib/image/ImageJobDescription.java Fri Dec 17 22:03:14 2010 +0100 +++ b/servlet/src/digilib/image/ImageJobDescription.java Mon Dec 20 09:39:14 2010 +0100 @@ -109,10 +109,8 @@ */ @Override protected void initOptions() { - if (options == null) { - String s = this.getAsString("mo"); - options = new OptionsSet(s); - } + String s = this.getAsString("mo"); + options = new OptionsSet(s); } @@ -376,7 +374,7 @@ return paramDH; } - public Integer get_scaleQual(){ + public Integer getScaleQual(){ logger.debug("get_scaleQual()"); Integer qual = dlConfig.getAsInt("default-quality"); if(hasOption("q0")) diff -r 4c51d71aef13 -r 8beefd1142b2 servlet/src/digilib/image/ImageLoaderDocuImage.java --- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Fri Dec 17 22:03:14 2010 +0100 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Mon Dec 20 09:39:14 2010 +0100 @@ -179,13 +179,18 @@ } RandomAccessFile rf = new RandomAccessFile(f.getFile(), "r"); ImageInputStream istream = new FileImageInputStream(rf); - // Iterator readers = ImageIO.getImageReaders(istream); + Iterator readers; String mt = f.getMimetype(); - logger.debug("File type:" + mt); - Iterator readers = ImageIO.getImageReadersByMIMEType(mt); + if (mt == null) { + logger.debug("No mime-type. Trying automagic."); + readers = ImageIO.getImageReaders(istream); + } else { + logger.debug("File type:" + mt); + readers = ImageIO.getImageReadersByMIMEType(mt); + } if (!readers.hasNext()) { rf.close(); - throw new FileOpException("Unable to load File!"); + throw new FileOpException("Can't find Reader to load File!"); } reader = readers.next(); /* are there more readers? */ @@ -302,15 +307,14 @@ AffineTransformOp scaleOp = new AffineTransformOp(AffineTransform .getScaleInstance(scale, scale), renderHint); BufferedImage scaledImg = null; - // enforce destination image type (*Java2D BUG*) + /* enforce destination image type (*Java2D BUG*) int type = img.getType(); - // FIXME: which type would be best? if ((quality > 0) && (type != 0)) { logger.debug("creating destination image"); Rectangle2D dstBounds = scaleOp.getBounds2D(img); scaledImg = new BufferedImage((int) dstBounds.getWidth(), (int) dstBounds.getHeight(), type); - } + } */ logger.debug("scaling..."); scaledImg = scaleOp.filter(img, scaledImg); if (scaledImg == null) { @@ -340,9 +344,10 @@ // blur with convolve operation ConvolveOp blurOp = new ConvolveOp(blur, ConvolveOp.EDGE_NO_OP, renderHint); + BufferedImage blurredImg = null; // blur needs explicit destination image type for color *Java2D BUG* - BufferedImage blurredImg = null; if (img.getType() == BufferedImage.TYPE_3BYTE_BGR) { + logger.debug("blur: fixing destination image type"); blurredImg = new BufferedImage(img.getWidth(), img.getHeight(), img .getType()); } @@ -354,9 +359,6 @@ throws ImageOpException { // setup Crop BufferedImage croppedImg = img.getSubimage(x_off, y_off, width, height); - // DEBUG - // util.dprintln(2, " time - // "+(System.currentTimeMillis()-startTime)+"ms"); if (croppedImg == null) { throw new ImageOpException("Unable to crop"); } @@ -386,12 +388,10 @@ } public void enhanceRGB(float[] rgbm, float[] rgba) throws ImageOpException { - /* * The number of constants must match the number of bands in the image. * We do only 3 (RGB) bands. */ - int ncol = img.getColorModel().getNumColorComponents(); if ((ncol != 3) || (rgbm.length != 3) || (rgba.length != 3)) { logger @@ -464,9 +464,7 @@ double xoff = rotbounds.getX(); double yoff = rotbounds.getY(); // move image back in line - trafo - .preConcatenate(AffineTransform.getTranslateInstance(-xoff, - -yoff)); + trafo.preConcatenate(AffineTransform.getTranslateInstance(-xoff, -yoff)); // transform image rotOp = new AffineTransformOp(trafo, renderHint); BufferedImage rotImg = rotOp.filter(img, null); diff -r 4c51d71aef13 -r 8beefd1142b2 servlet/src/digilib/image/ImageWorker.java --- a/servlet/src/digilib/image/ImageWorker.java Fri Dec 17 22:03:14 2010 +0100 +++ b/servlet/src/digilib/image/ImageWorker.java Mon Dec 20 09:39:14 2010 +0100 @@ -48,7 +48,7 @@ } // set interpolation quality - docuImage.setQuality(jobinfo.get_scaleQual()); + docuImage.setQuality(jobinfo.getScaleQual()); Rectangle loadRect = jobinfo.getOuterUserImgArea().getBounds(); float scaleXY = jobinfo.getScaleXY(); @@ -61,7 +61,7 @@ if (scaleXY < 1) { subf = 1 / scaleXY; // for higher quality reduce subsample factor by minSubsample - if (jobinfo.get_scaleQual() > 0) { + if (jobinfo.getScaleQual() > 0) { subsamp = (float) Math.max(Math.floor(subf / dlConfig.getAsFloat("subsample-minimum")), 1d); } else { subsamp = (float) Math.floor(subf);