class ActiveStorage::Previewer
def capture(*argv, to:)
def capture(*argv, to:) to.binmode open_tempfile do |err| IO.popen(argv, err: err) { |out| IO.copy_stream(out, to) } err.rewind unless $?.success? raise PreviewError, "#{argv.first} failed (status #{$?.exitstatus}): #{err.read.to_s.chomp}" end end to.rewind end