image_processing: VipsForeignLoad: "/tmp/ActiveStorage-28657-20220112-4-8e2faa.jpg" is not a known file format
Bug report
Describe the bug
Somehow when trying to process an image I got this error:
VipsForeignLoad: "/tmp/ActiveStorage-28657-20220112-4-8e2faa.jpg" is not a known file format
To Reproduce
Steps to reproduce the behavior:
- user uploads an image
- I transform it using rails’s active storage
attachment.file.variant(**options).processed - See error
Expected behavior
Either says the file is not found somehow (maybe because of a server/dyno restart?) (I’m on Heroku), or maybe a missing package? not sure
Or actually process the file and return a new processed file
Actual behavior
Errors out
Environment
- OS: (
uname -a)Linux c5450f47-0d17-4a40-8f95-2c64a40e8e2c 4.4.0-1097-aws #102-Ubuntu SMP Fri Sep 10 22:18:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux - Vips: I can’t seem to find it, it’s on Heroku, I used an Aptfile to install
libvips, probably the latest on the latest stable version of ubuntu
Additional context
I’m on a rails app, users can upload images, I process them (size, remove filenames, remove metadata, optimize, etc.)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (3 by maintainers)
Why would an
ActiveStorage::Blob.downloadreturn""Does this means the file was not uploaded?This is how the blob record looks like
When you try to read the same file with vips you get this issue.
Error:
Yes, that’s expected behaviour. I think we used to special-case zero length files and have a different error message, but we removed it for simplicity.
Would you prefer a special message for this?
For those who land on this issue looking for a solution:
Easiest option is to install
libvips-devso that it installs all the require dependancies. This will install all the required libraries to support all the major file formats.If you are building libvips from source you need to install the optional dependancies yourself before you install
libvips. You will see inlibvipsinstall instructions that it has many optional dependancies: https://www.libvips.org/install.html.Pick the libraries required for the file formats you want to support or almost all of them with the following before you try to build from source. The following will install support for all major formats.
@janko Here is a sample app: https://github.com/tsrivishnu/tmp-rails-libvips-jpg-failures that you can run in docker. The README has the instructions to run it in Docker. Make sure you adapt the Dockerfile as in the first point under Setup. Let me know if you are able to reproduce it.