-3

How can I get an image from LMDB in Python?

And what is the data type of that result? Would that data type match the function open('xx.jpg').read()?

My purpose is to read an image from LMDB, and then match my code (that code is written for the data type of open('xx.jpg').read()), so I want to get the same data type from LMDB if I can.

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71

1 Answers1

-1

It depends on the layout of the IMDB page you wish to get this image from. If it is simply a pure jpg url, you can do this:

import urllib
import image

urllib.urlretrieve("http://ia.media-imdb.com/images/M/MV5BMTg2NDE5NDEyNl5BMl5BanBnXkFtZTgwOTA3MzgwNjE@._V1_UX100_CR0,0,100,100_AL_.jpg", "moviePoster.jpg")

jpgfile = image.open("moviePoster.jpg")

If the url doesn't lead to a single jpg file, you might want to look into using a library like beautiful soup, in order to search for the images first

user3636636
  • 2,409
  • 2
  • 16
  • 31