Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Bash script with Image Magick to a Java program Date: Fri, 27 May 2016 23:23:19 +0200 Organization: Decebal Computing Lines: 62 Message-ID: <877fef2o1k.fsf@Equus.decebal.nl> References: <87oa7s4f1u.fsf@Equus.decebal.nl> <8760tz50qf.fsf@Equus.decebal.nl> <871t4n4u12.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="22259"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1824olgxfhKXfT5qDJZHPfK98XW1aPGqdQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:LhpWEywTZSNgMt0FDmW1mFkDoHM= sha1:adGTuU/V5ByVF/U+3sA5N+h3yuY= Xref: csiph.com comp.lang.java.programmer:34408 On Friday 27 May 2016 20:02 CEST, Martin Gregorie wrote: > I'm using: > import java.awt.RenderingHints; > import java.awt.geom.AffineTransform; > import java.awt.image.AffineTransformOp; > import java.awt.image.BufferedImage; > import java.awt.image.BufferedImageFilter; > import java.awt.image.BufferedImageOp; > import java.awt.image.RescaleOp; > import java.io.File; > import java.io.IOException; > import java.util.Hashtable; > import javax.imageio.ImageIO; > import org.gregorie.environ.ReportError; > > ... but obviously not all of them are being used to resize an image. > Here's the code: > > public void resizeTo(int width) > { > re.trace(2, "resizeTo(" + width + ") started"); > int w = im.getWidth(); > int h = im.getHeight(); > double scale = width * 1.0 / w; > > if (noExpand && scale >= 1.0) > { > wouldExpand = true; > re.trace(2, "Image is smaller than " + width + > " wide: original size will be output"); > } > else > { > wouldExpand = false; > AffineTransform at = new AffineTransform(); > at.scale(scale, scale); > AffineTransformOp op = new AffineTransformOp(at, > AffineTransformOp.TYPE_BICUBIC); > Double nw = new Double(w * scale); > Double nh = new Double(h * scale); > re.trace(2, "scale=" + scale + > " new size w=" + nw.intValue() + > " h=" + nh.intValue()); > re.trace(3, "Source buffer details: " + im); > om = new BufferedImage(nw.intValue(), > nh.intValue(), > BufferedImage.TYPE_3BYTE_BGR); > op.filter(im, om); > } > > re.trace(1, "resizeTo(" + width + ") done"); > } > > The re.trace() calls are to my private traceing/debugging class I will look into it. Thanks. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof