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

Large temp file creation when a video is analysed #526

Open
brendon opened this issue Oct 24, 2024 · 0 comments
Open

Large temp file creation when a video is analysed #526

brendon opened this issue Oct 24, 2024 · 0 comments

Comments

@brendon
Copy link

brendon commented Oct 24, 2024

Hi @markevans, I'm hoping you can help me figure out a plan to solve this thorny issue :)

I have a generic file store that uses plugin :imagemagick so that I can transform images if they're detected as such, but it's an open ended store, so users can upload any kind of file there. Unfortunately imagemagick chokes when you ask it to identify a mp4 file. A user uploaded a 200MB mp4 and imagemagick proceeded to use up 15GB of disk space and crash the machine.

I know there are ways to limit all of those side effects but I think the best thing would be to add a pre-check to ensure we're dealing only with real images before invoking identify. Imagemagick seems to be capable of processing video files but at great cost, so it's probably worth skipping in this case.

Initial thoughts were to run something like file --mime-type -b video.mp4 and check the type there, or perhaps there's a Ruby equivalent that's better suited and safer.

Would this be the best place for it?

app.add_analyser :image do |content|
begin
content.analyse(:image_properties)["format"] != "pdf"
rescue Shell::CommandFailed
false
end
end

And finally, is this just something I can override myself by adding something like this to my dragonfly configuration?

  analyser :image do |content|
    # Detection Override
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant