Uploaded image for project: 'VIVO'
  1. VIVO
  2. VIVO-1674

Improve quality of thumbnails created by VIVO



    • Attachments:
    • Comments:


      The VIVO image processor that creates thumbnails from uploaded images does not do a good job of scaling the image. The result is a very grainy, pixelated thumbnail. Some bits of conversation from Slack:


      Don Elsborg [10:21 AM]
      help please. Can someone with a 1.10 instance verify if the images for the profile page get grainy during the thumbnail resize process?

      Benjamin Gross [10:27 AM]
      Can you post a photo so we can do a 1:1 comparison of the thumbnail created?
      And are you looking for someone to test in general, or specifically using openjdk?

      Don Elsborg [10:41 AM]
      test in general to start. But specifically openjdk

      Don Elsborg [10:48 AM]
      here's a quick example, the profile pic is grainy. If I copy the main image and resize it to the size of the profile pic, the resize in my image editor is much more clear. I'll look around for other images that are more blatent

      Benjamin Gross [11:08 AM]
      Result still appears to be grainy, 1.10 on oracle jdk

      Don Elsborg [11:10 AM]
      here's another one with strange thumbnail effects: https://experts.colorado.edu/display/fisid_101695
      did your test include the image commits that you emailed about?
      also, we're on openjdk, I noticed the group of commits you emailed about last week pertained to openjdk. Any way you can test that with openjdk? Side note - what version of VIVO is openvivo.org? If it's 1.10 I can test myself there.
      @Andrew Woods getting internal error when logging into openvivo

      Benjamin Gross [11:14 AM]
      Classic OpenVIVO

      Andrew Woods [11:15 AM]
      on a call

      Benjamin Gross [11:17 AM]
      OpenVIVO is not 1.10, or really any release. It was forked from VIVO... I think sometime during the 1.9.x days.
      And yes, my test included the image processor changes. Testing on 1.10.
      The resultant thumbnail posted above is 12kb. So the image processor is being really aggressive about compressing.

      Don Elsborg [11:20 AM]
      thanks as always @Benjamin Gross . I'm taking a look in this area for scaling factors:
      Per document at: https://memorynotfound.com/java-resize-image-fixed-width-height-example/
      Java Resize Image to Fixed Width and Height Example - Memorynotfound
      In this tutorial we show a Java Resize Image to Fixed Width and Height Example. We can resize an image using different algorithms. Each algorithm focuses on a different aspect. You can configure the...
      Oct 24th, 2017

      Benjamin Gross [11:39 AM]
      I think there are a couple things are work here. First, no clue what kind of interpolation is happening at https://github.com/vivo-project/Vitro/blob/develop/api/src/main/java/edu/cornell/mannlib/vitro/webapp/imageprocessor/imageio/IIOImageProcessor.java#L152. If it defaults to nearest neighbor we're going to get bad results on everything that's not square. We probably want to use bicubic. Second, I don't think we're setting the compression at https://github.com/vivo-project/Vitro/blob/develop/api/src/main/java/edu/cornell/mannlib/vitro/webapp/imageprocessor/imageio/IIOImageProcessor.java#L171, which maybe we could set to a more reasonable value.

      Don Elsborg [11:46 AM]
      you thinking something like answer 40 in: https://stackoverflow.com/questions/17108234/setting-jpg-compression-level-with-imageio-in-java
      Stack Overflow
      Setting jpg compression level with ImageIO in Java
      I'm using javax.imageio.ImageIO to save a BufferedImage as a jpeg file. In particular, I created the following Java function: public static void getScreenShot(BufferedImage capture, Path folder, ...

      Andrew Woods [12:10 PM]
      @Don Elsborg: give openvivo a shot now

      Don Elsborg [12:12 PM]
      @Andrew Woods I'm in. Thanks

      Don Elsborg [12:33 PM]
      aha @Benjamin Gross it does default to nearest neighbor - see https://docs.oracle.com/javase/8/docs/api/index.html?java/awt/image/AffineTransformOp.html

      Don Elsborg [1:00 PM]
      See this comment on AffineTransformOp "When scaling an image down, and more generally with any affine transform, you can choose between speed and quality. Using AffineTransformOp.TYPE_NEAREST_NEIGHBOR as the second argument in your AffineTransformOp constructor will give you speed. For the best quality use AffineTransformOp.TYPE_BICUBIC. AffineTransformOp.TYPE_BILINEAR balances speed and quality." from the book https://learning.oreilly.com/library/view/learning-java-4th/9781449372477/ch21s03.html


          Issue Links



              mbgross Benjamin Gross
              mbgross Benjamin Gross
              Andrew Woods
              0 Vote for this issue
              3 Start watching this issue