Closed GoogleCodeExporter closed 9 years ago
Unable to reproduce (However not that the Easizer is not up-to-date!)
I have attached a testcase (with version 0.8.4 downloaded from
http://code.google.com/p/java-image-scaling/ ) that works on my machine.
Please let me know if you still have problems.
Original comment by m%nobel-...@gtempaccount.com
on 26 Mar 2010 at 7:33
Attachments:
I'm using version 0.8.4 and experienced the same problem.
int maxheightwidth = 150;
BufferedImage img = ImageIO.read(new ByteArrayInputStream(data));
int width = img.getWidth();
int height = img.getHeight();
if (height > maxheightwidth || width > maxheightwidth) {
if (height > width) {
// height > width
float ratio = (float) maxheightwidth / height;
height = maxheightwidth;
width = (int) (ratio * width);
} else {
float ratio = (float) maxheightwidth / width;
width = maxheightwidth;
height = (int) (ratio * height);
}
// image = image.scaleImage(width, height);
}
ResampleOp resampleOp = new ResampleOp(width, height);
resampleOp.setNumberOfThreads(4);
resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
BufferedImage rescaledImage = resampleOp.filter(img, null);
ByteArrayOutputStream b = new ByteArrayOutputStream();
ImageIO.write(rescaledImage, this.format.toLowerCase(), b);
data = b.toByteArray();
Original comment by tbr...@gmail.com
on 15 Apr 2010 at 10:53
Attachments:
Thanks for the feedback.
What version of Java are you using? And on what platform?
Original comment by m%nobel-...@gtempaccount.com
on 16 Apr 2010 at 5:58
I tested this on debian (64 bit):
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) 64-Bit Server VM (build 11.2-b01, mixed mode)
and on my local windows 7 machine (64bit):
jdk1.6.0_19 (32 bit as I only had 32 bit imagemagick ddl available)
Original comment by tbr...@gmail.com
on 16 Apr 2010 at 12:37
I can reproduce it with the following test case. If you output the rescaled
image as
png, the problem doesn't occur!
I also ran this in a fresh project (with only the filter, junit and
image-scaling
library), so it's definitely not some jar library conflict.
Original comment by tbr...@gmail.com
on 16 Apr 2010 at 1:40
Attachments:
I'm pretty sure that the problem only occur if both rescale the image and
change from
one image type to another.
Original comment by m%nobel-...@gtempaccount.com
on 16 Apr 2010 at 2:11
I can confirm that keeping same image format is reasonable workaround, and to
get format name just use the following code:
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(img.imgData);
ImageInputStream imageInputStream =
ImageIO.createImageInputStream(byteInputStream);
Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(imageInputStream);
BufferedImage bigImg = ImageIO.read(imageInputStream);
String formatName;
if(imageReaders.hasNext())
{
ImageReader imageReader = imageReaders.next();
formatName = imageReader.formatName;
}
Original comment by marcin.l...@gmail.com
on 21 Nov 2010 at 10:06
I'm closing this bug, since I believe the bug relates to the ImageIO more than
ImageScaling library.
Original comment by m%nobel-...@gtempaccount.com
on 5 Feb 2011 at 1:43
So if someone has to do it how can it be done?
Original comment by vramd...@gmail.com
on 20 Apr 2011 at 9:14
You can use the workaround suggested by marcin:
http://code.google.com/p/java-image-scaling/issues/detail?id=18#c7
Original comment by m%nobel-...@gtempaccount.com
on 20 Apr 2011 at 7:04
Original issue reported on code.google.com by
tros...@gmail.com
on 26 Mar 2010 at 11:09