0

I have a web app that will show gallery of thumbnails. My problem is, some images are very huge (like 6000 x 6000), and my current approach is load the image into image tag, then use css to set max-width and max-height, which is very slow because of the huge image loaded behind.

What is the easiest solution for this situation?

I am using Rails, and the images are uploaded using Carrierwave.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
VHanded
  • 2,079
  • 4
  • 30
  • 55

1 Answers1

2

Try looking at the image thumbnails section on the Carrierwave github page. The idea is that when a large image is uploaded, you can resize the image and store a copy of it. Later on, you can then serve a smaller version of the image to make the request times much faster.

You may also want to keep the proper aspect ratio in the image uploaded by using 0 or nil as the width or height you want to be dependent on the other attribute. Have a look here for more information.

Community
  • 1
  • 1
jvperrin
  • 3,368
  • 1
  • 23
  • 33
  • 2
    Yep making a smaller copy is best way to go. For big pics like that I would also try to move resizing into background process using `carrierwave_backgrounder`gem. – Serge Vinogradoff Oct 23 '13 at 00:28