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
Extract metadata from images and videos #30944
Extract metadata from images and videos #30944
Conversation
private | ||
def read_image | ||
download_blob_to_tempfile do |file| | ||
require "mini_magick" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is mini_magick
a dependency of Rails now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s an optional Active Storage dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we gracefully fail for this require here telling people to include the gem if they don't have?
end | ||
|
||
def probe_from(file) | ||
IO.popen([ "ffprobe", "-print_format", "json", "-show_streams", "-v", "error", file.path ]) do |output| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the machines doesn't have ffprobe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An Errno::ENOENT
exception would have been raised. FFmpeg commonly won’t be installed at first, so I switched to logging an informative message and failing gracefully in 1d4b6db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small concern about gracefully failing when the libraries are not available but this looks good to me.
private | ||
def read_image | ||
download_blob_to_tempfile do |file| | ||
require "mini_magick" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we gracefully fail for this require here telling people to include the gem if they don't have?
end | ||
|
||
def probe_from(file) | ||
IO.popen([ "ffprobe", "-print_format", "json", "-show_streams", "-v", "error", file.path ]) do |output| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1,13 @@ | |||
# frozen_string_literal: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no strings in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubocop doesn't make that distinction. And even if it could, of two bad options, I think I'd prefer to always add this when creating new files than add it when a later edit happens to introduce a string.
Provide two built-in analyzers, one for images and the other for videos. Analyze a blob when it’s attached for the first time.