rajkumarsaroj / java-image-scaling

Automatically exported from code.google.com/p/java-image-scaling
Other
0 stars 0 forks source link

When scale images smaller than 150kb, the resulting image comes out like a negative #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Below is the code that i use:

Double rescaledWidth = 400.00;
Double rescaledHeight= 450.00;

File scaledFile = new File(path + "/" + fileNamePrefix +"_"+ key);
ResampleOp resampleOp = new ResampleOp (rescaledWidth,rescaledHeight);
resampleOp.setUnsharpenMask(UnsharpenMask.Normal);
BufferedImage rescaledImage = resampleOp.filter(origBufferedImage, null);
ImageIO.write(rescaledImage, fileExt, scaledFile);

and i have attached an image which comes out as negetive, let me know if it is 
a problem with the way i use your api or it is a bug in the api.

Thanks for the quick response earlier.

Pratap

Original issue reported on code.google.com by prata...@gmail.com on 15 Nov 2011 at 8:40

GoogleCodeExporter commented 8 years ago
Sorry do not use the above image. try this one:

Original comment by prata...@gmail.com on 15 Nov 2011 at 8:45

Attachments:

GoogleCodeExporter commented 8 years ago
I think, this happens with images smaller than 125kb.

Original comment by prata...@gmail.com on 15 Nov 2011 at 8:46

GoogleCodeExporter commented 8 years ago
It works fine for me.

Could you try to run the attached test-case on your machine?

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 9:07

Attachments:

GoogleCodeExporter commented 8 years ago
Here is the link: http://cqpt.co/rBPYkk
the answer is pratap

I will run a test in my local machine

Original comment by prata...@gmail.com on 15 Nov 2011 at 9:29

GoogleCodeExporter commented 8 years ago
Also please provide what version of Java and what OS you are using.

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 9:36

GoogleCodeExporter commented 8 years ago
Java 6 and Linux (Amazon Linux AMI)

Original comment by prata...@gmail.com on 15 Nov 2011 at 9:39

GoogleCodeExporter commented 8 years ago
I need the exact java version. (Type 'java -version' in the terminal)

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 9:41

GoogleCodeExporter commented 8 years ago
Hey, tested it locally. It works perfect. But when i do it in production env, 
it gets messed up. Any clue as to what might be happening?

Original comment by prata...@gmail.com on 15 Nov 2011 at 9:47

GoogleCodeExporter commented 8 years ago
1.6.0_20

Original comment by prata...@gmail.com on 15 Nov 2011 at 9:48

GoogleCodeExporter commented 8 years ago
1.6.0_20 should be ok. (It is the same java version in your production 
environment?)

One thing I notised in your code is that you use double for width and height. 
The library only supports ints. Maybe try to write out the dimensions to 
System.out (or to a log-file) before you resize.

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 9:51

GoogleCodeExporter commented 8 years ago
Actually i pass int (i convert the double at some point)

Original comment by prata...@gmail.com on 15 Nov 2011 at 10:17

GoogleCodeExporter commented 8 years ago
I think it is related to this issue:
http://code.google.com/p/java-image-scaling/issues/detail?id=18#c7

Check out the workaround by marcin

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 10:34

GoogleCodeExporter commented 8 years ago
Will check, thanks a ton for your help. 

Original comment by prata...@gmail.com on 15 Nov 2011 at 11:20

GoogleCodeExporter commented 8 years ago
http://stackoverflow.com/questions/4386446/problem-using-imageio-write-jpg-file

I guess you are right the problem is with ImageIO

Original comment by prata...@gmail.com on 15 Nov 2011 at 12:22

GoogleCodeExporter commented 8 years ago
Great :) I'll close the issue then

Original comment by mor...@nobel-joergensen.com on 15 Nov 2011 at 12:41

GoogleCodeExporter commented 8 years ago
Just checked, it is working great. BTW thanks a ton for the support and help. 

Original comment by prata...@gmail.com on 15 Nov 2011 at 1:14