title: Convert Binary Data to Torch Tensor in Lua
body: <p>I have Lua code that downloads an image from a url using a luasocket:</p>
  
  <pre><code>local http = require('socket.http')
  local image = require('image')
  
  image_url = 'https://www.somedomain.com/someimage.jpg'
  local body, code = http.request(image_url) -- body has jpg binary data
  if not body then error(code) end -- check for errors
  </code></pre>
  
  <p>In order to read this image into a Torch tensor, I save it in a jpg file and read it using <code>image.load</code>:</p>
  
  <pre><code>-- open a file in binary mode to store the image
  local f = assert(io.open('./temp.jpg', 'wb')) 
  f:write(body)
  f:close()
  
  tensor = image.load('temp.jpg')
  </code></pre>
  
  <p>Is there a way to convert the binary jpg data to a torch tensor directly without doing a write-to-and-read-from the hard-drive? Something like:</p>
  
  <pre><code>tensor = CovertBinaryDataToTorchTensor(body)
  </code></pre>
  
  <p>Thank you!</p>