This is a good trick when you're standardizing image size and quality based on project requirements. On my last project we knew the images were going into 2x3" panels in a PDF document and could reduce everything to around 20k.

Bob Carpenter wrote:
I didn't know that ImageIO reduces quality with each pass. ImageIO is used
at least twice for each file because it gets stored as a BLOB and is served
to clients by saving to disk then reading back in with ImageIO.

Thanks for the clue - I'll start looking down that path.

--BobC


-----Original Message-----
From: Emmanuel Bourg [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2008 2:18 PM
To: Commons Users List
Subject: Re: Blurry JPGs when using FileUpload 1.2.1


You should write the uploaded image directly to the disk, you reduce its
quality every time your read and write it with ImageIO.

Emmanuel Bourg


Bob Carpenter a écrit :
Hi,

Using FileUpload 1.2.1 with Struts the image quality of my JPGs are
blurry.
I've had this problem for a couple years, but was hoping that v1.2.1 would
solve the problem.

You can view the before and after images here:

  http://www.customerfeedbackllc.com/dev/receipt_before_upload.jpg
  http://www.customerfeedbackllc.com/dev/receipt_after_upload.jpg

Here is the code from my Struts Action class that does the work:

  String uploadFilePath = form.getUploadFilePath();
  InputStream is = uploadFile.getInputStream();  // uploadFile is a
FormFile
  BufferedImage bufiIn = ImageIO.read(is);

  // bufiIn is stored in a custom object (TransferImage, which extends
Canvas and is Serializable) - here are the essential steps
  int[] imgPix = (int[])pix;
  int width = bufiIn.getWidth();
  int height = bufiIn.getHeight();

  BufferedImage bufiOut = new BufferedImage(width, height,
BufferedImage.TYPE_INT_BGR);
  image.setRGB(0, 0, width, height, imgPix, 0, width);

  // Write the bufi to a tmp file for viewing
  ImageIO.write(bufiOut, "jpg", new
File("c:\\tmp\\receipt_after_upload.jpg"));

The receipt_before_upload.jpg comes from a camera phone. Usually, images
coming from scanners are not as blurry.

Can you suggest any way to reduce the blurriness?

Thanks,

--BobC


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to