Skip to content
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

Merged
merged 6 commits into from Oct 22, 2017
Merged

Extract metadata from images and videos #30944

merged 6 commits into from Oct 22, 2017

Conversation

@georgeclaghorn
Copy link
Contributor

@georgeclaghorn georgeclaghorn commented Oct 20, 2017

Provide two built-in analyzers, one for images and the other for videos. Analyze a blob when it’s attached for the first time.

private
def read_image
download_blob_to_tempfile do |file|
require "mini_magick"

This comment has been minimized.

@rafaelfranca

rafaelfranca Oct 20, 2017
Member

is mini_magick a dependency of Rails now?

This comment has been minimized.

@georgeclaghorn

georgeclaghorn Oct 20, 2017
Author Contributor

It’s an optional Active Storage dependency.

This comment has been minimized.

@rafaelfranca

rafaelfranca Oct 20, 2017
Member

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|

This comment has been minimized.

@rafaelfranca

rafaelfranca Oct 20, 2017
Member

what happens if the machines doesn't have ffprobe?

This comment has been minimized.

@georgeclaghorn

georgeclaghorn Oct 20, 2017
Author Contributor

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.

This comment has been minimized.

Copy link
Member

@rafaelfranca rafaelfranca left a comment

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"

This comment has been minimized.

@rafaelfranca

rafaelfranca Oct 20, 2017
Member

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|

This comment has been minimized.

@georgeclaghorn georgeclaghorn merged commit 6054840 into rails:master Oct 22, 2017
@georgeclaghorn georgeclaghorn deleted the georgeclaghorn:activestorage-metadata branch Oct 22, 2017
@@ -0,0 +1,13 @@
# frozen_string_literal: true

This comment has been minimized.

@dhh

dhh Oct 24, 2017
Member

There are no strings in this file.

This comment has been minimized.

@matthewd

matthewd Oct 24, 2017
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants