-
-
Notifications
You must be signed in to change notification settings - Fork 139
"Skipping image analysis because ImageMagick or Vips doesn't support the file" when using open-uri to import images #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
To further complicate testing, since the gem declares both ruby-vips and minimagick as development dependencies, the Probably this could be done by removing that dependency from the gemspec and making one gemfile for ruby-vips and one for minimagick for all the possible combinations. FWIW, this is something that https://github.com/thoughtbot/appraisal is good for. |
Hi there,
and voilà, would be happy to remove those unnecessary steps if anyone has a better solution that works out of the box? |
A slightly simpler workaround is to make sure you provide a
|
Hi @olbrich, @jorge-d and @jaredmoody |
When using OpenURI to import an image from a URL, I get the error
"Skipping image analysis because ImageMagick or Vips doesn't support the file".
I think this only happens when using Vips as an image processor.
When trying to open urls for large images, OpenURI will return an IO object pointing to a tempfile. That tempfile does not have an extension indicating the type of file, which prevents the code from accurately determining the file type.
For some reason, there is a check in this code...
active_storage_validations/lib/active_storage_validations/metadata.rb
Lines 78 to 90 in b970f95
...that makes sure that the file is a type that Vips can handle before letting ImageMagick try to handle it. Since no extension exists on the tempfile, this always fails. In my experiments, Vips is actually able to properly determine the file type from the contents, so that check may not be needed (although this could be dependent on the version of Vips).
Also, it is possible to do this..
But the validator ignores the
filename
andcontent_type
hints unless the IO is a StringIO.Suggested Fixes:
filename
option.When using OpenURI for this kind of thing it is possible for the contents of the IO to be something like an HTML error page instead of an image, so relying on the extension to determine types may not be reliable.
Related to #176 and #154
The text was updated successfully, but these errors were encountered: