Problem:
- The application crashed when attempting to resize the image to a size of 50px x 50px.
- ActiveStorage was properly configured with the required dependencies.
def image_as_thumbnail
image.variant(resize_to_limit: [50, 50]).processed
end
<td class="py-4 px-6 text-sm font-medium text-purple-500 whitespace-nowrap dark:text-white">
<%= c.image.present? ? image_tag(c.image_as_thumbnail) : image_tag("https://via.placeholder.com/50") %>
</td>
- The following error message occurred when running the app:
| LoadError (Could not open library 'vips.so.42': vips.so.42: cannot open shared object file: No such file or directory.
17:41:13 web.1 | Could not open library 'libvips.so.42': libIlmImf-2_5.so.25: cannot open shared object file: No such file or directory.
17:41:13 web.1 | Searched in <system library path>, /usr/lib, /usr/local/lib, /opt/local/lib):
17:41:13 web.1 |
-
Libvips
was already installed. -
Installed the missing dependencies:
sudo apt-get install libopenexr-dev
- Received the following error message:
The following packages have unmet dependencies:
libopenexr-dev : Depends: libopenexr25 (= 2.5.7-1ubuntu0.1~esm1) but 2.5.8-0ubuntu1~22.04.sav1 is to be installed
E: Unable to correct problems, you have held broken packages.
Solution:
- Checked for conflicting packages:
sudo apt-mark showhold
-
Found no held packages.
-
Installed ImageMagick:
sudo apt-get install imagemagick
- Downgraded to libopenexr25:
sudo apt-get install libopenexr25=2.5.7-1ubuntu0.1~esm1
- Installed libopenexr:
sudo apt-get install libopenexr-dev
- Fixed broken packages:
sudo apt-get install -f
- Reinstalled libopenexr:
sudo apt-get install libopenexr-dev
Following these steps resolved the issue with libopenexr and ensured that libvips could be used successfully for image resizing within the Rails ActiveStorage environment.