Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:25:47+00:00 2026-05-23T13:25:47+00:00

I’m trying to create thumbnails for uploaded images in a JRuby/Rails app using the

  • 0

I’m trying to create thumbnails for uploaded images in a JRuby/Rails app using the Image Voodoo plugin – the problem is the resized thumbnails look like… ass.

It seems that the code to generate the thumbnails is absolutely doing everything correctly to set the interpolation rendering hint to “bicubic”, but it isn’t honoring them on our dev environment (OS X), or on the production web server (Linux).

I’ve extracted out the code to generate the thumbnails, rewritten it as a straight Java app (ie kicked off from a main() method) with the interpolation rendering hint explicitly set to “bicubic”, and have reproduced the (lack of) bicubic and bilinear resizing.

As expected on both OS X and Linux the thumbanils are ugly and pixelated, but on Windows, it resizes the images nicely with bicubic interpolation used.

Is there any JVM environment setting and/or additional libraries that I’m missing to make it work? I’m doing a lot of banging of head against wall for this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:25:47+00:00Added an answer on May 23, 2026 at 1:25 pm

    I realize this question was asked a while ago, but incase anyone else is still running into this.

    The reason the thumbnails look like ass are caused by two things (primarily the first one):

    • Non-incremental image scaling in Java is very rough, throws a lot of pixel data out and averages the result once regardless of the rendering hint.
    • Processing a poorly supported BufferedImage type in Java2D (typically GIFs) can result in very poor looking/dithered results.

    As it turns out the old AreaAveragingScaleFilter does a decent job of making good looking thumbnails, but it is slow and deprecated by the Java2D team — unfortunately they didn’t replace it with any nice out-of-the-box alternative and left us sort of on our own.

    Chris Campbell (from the Java2D team) addressed this a few years ago with the concept of incremental scaling — instead of going from your starting resolution to the target resolution in one operation, you do it in steps, and the result looks much better.

    Given that the code for this is decently large, I wrote all the best-practices up into a library called imgscalr and released it under the Apache 2 license.

    The most basic usage looks like this:

    BufferedImage img = ImageIO.read(...); // load image
    BufferedImage scaledImg = Scalr.resize(img, 640);
    

    In this use-case the library uses what is called it’s “automatic” scaling mode and will fit the resulting image (honoring it’s proportions) within a bounding box of 640×640. So if the image is not a square and is a standard 4:3 image, it will resize it to 640×480 — the argument is just it’s largest dimension.

    There are a slew of other methods on the Scalr class (all static and easy to use) that allow you to control everything.

    For the best looking thumbnails possible, the command would look like this:

    BufferedImage img = ImageIO.read(...); // load image
    BufferedImage scaledImg = Scalr.resize(img, Method.QUALITY, 
                                           150, 100, Scalr.OP_ANTIALIAS);
    

    The Scalr.OP_ANTIALIAS is optional, but a lot of users feel that when you scale down to a small enough thumbnail in Java, some of the transitions between pixel values are a little too discrete and make the image look “sharp”, so a lot of users asked for a way to soften the thumbnail a bit.

    That is done through a ConvolveOp and if you have never used them before, trying to figure out the right “kernel” to use is… a pain in the ass. That OP_ANTIALIAS constant defined on the class it the best looking anti-aliasing op I found after a week of testing with another user who had deployed imgscalr into their social network in Brazil (used to scale the profile photos). I included it to make everyone’s life a bit easier.

    Also, ontop of all these examples, you might have noticed when you scale GIFs and some other types of images (BMPs) that sometimes the scaled result looks TERRIBLE compared to the original… that is because of the image being in a poorly supported BufferedImage type and Java2D falling back to using it’s software rendering pipeline instead of the hardware accelerated one for better supported image types.

    imgscalr will take care of all of that for you and keep the image in the best supported image type possible to avoid that.

    Anyway, that is a REALLY long way of saying “You can use imgscalr to do all that for you and not have to worry about anything”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.