Comments (4)
I'm unable to reproduce the problem in 0.8.2 (just released). I suspect the
error
report is about 0.8.1 (even though is says 0.8.2).
I case I'm wrong, please provide me with a full code example (I'm currently
using the
one below):
BufferedImage image2D =
ImageIO.read(getClass().getResourceAsStream("issue11.jpg"));
DimensionConstrain dc = DimensionConstrain.createMaxDimension(604,604, true);
ResampleOp resampleOp = new ResampleOp (dc);
BufferedImage rescaledTomato = resampleOp.filter(image2D, null);
Original comment by m%[email protected]
on 3 Nov 2009 at 2:42
- Changed state: WontFix
from java-image-scaling.
I downloaded 8.3 jar and works with no exception now. However the rescaling
seem to
have reduce some quality of the original. I have attached the rescaled of the
previous attached photo. There are extra white shadow around the white part of
the
picture which dont exist from the original.
Here is the code i use:
BufferedImage bi = ImageIO.read(src);
DimensionConstrain dc =DimensionConstrain.createMaxDimension(604,604, true);
ResampleOp resampleOp = new ResampleOp(dc);
resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Soft);
BufferedImage rescaled = resampleOp.filter(bi,null);
File outfile = new File("/Users/charlie/Development/java/playSe/"+ file
+".jpg");
javax.imageio.ImageIO.write(rescaled, "jpg", outfile);
Original comment by [email protected]
on 5 Nov 2009 at 10:08
Attachments:
from java-image-scaling.
Ok. It seems to be a problem. It must be related to the file format (Grayscale
jpegs). If the source image is saved as png, there is no problem.
The wierd thing is that in my IDE (IntelliJ) there is actually also white noise
on
the source image as well.
I'll look at it.
Original comment by m%[email protected]
on 11 Nov 2009 at 8:19
- Changed state: Accepted
from java-image-scaling.
I figured out what is wrong. The rescale works as intended - the white shadows
is
created by the jpeg compression.
To fix it simply choose a lossless format (such as png) or increase the jpeg
quality
using the following code:
private void saveHighqualityJpeg(BufferedImage rescaledTomato, String filename)
throws IOException {
ImageWriter writer = null;
Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
if (iter.hasNext()) {
writer = (ImageWriter)iter.next();
}
FileOutputStream fos = new FileOutputStream(filename);
ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
writer.setOutput(ios);
ImageWriteParam iwparam = writer.getDefaultWriteParam();
iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
System.out.println(iwparam.getCompressionQuality()) ;
iwparam.setCompressionQuality(1.0f) ;
writer.write(null, new IIOImage(rescaledTomato, null, null), iwparam);
writer.dispose();
ios.close();
fos.close();
}
Original comment by m%[email protected]
on 29 Dec 2009 at 7:19
- Changed state: Fixed
from java-image-scaling.
Related Issues (20)
- Error scaling png, still not working HOT 10
- DimensionConstrain class is written in a way that cannot be extended HOT 3
- Problem with images rotating after scaling HOT 1
- Create square pic HOT 2
- Upscaling shift HOT 3
- proportional scaling HOT 1
- Rescaling with alpha HOT 1
- Jar file incomplete HOT 1
- Naming error: ThumpnailRescaleOp Thump -> Thumb HOT 1
- ArrayIndexOutOfBoundsException when upscaling a very small image HOT 2
- When scale images smaller than 150kb, the resulting image comes out like a negative HOT 16
- Code cleanup & ant unit test tasks
- Wrong license refererenced in maven pom file
- Incorrect implementation of getBounds2D and getPoint2D HOT 1
- Android version
- Aspect Ratio Issue HOT 1
- e.printStackTrace() inside a catched exception HOT 3
- Resize fails for TYPE_USHORT_GRAY image
- Adding method ResampleFilters.valueOf(String name)
- Push version 0.8.6 to maven central HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-image-scaling.