docs: def image_opener(key):
      """Handler to locate file based on key.
  
      :param key: A key encoded in the format "<bucket>:<version>:<object_key>".
      :returns: A file-like object.
      """
      if hasattr(g, 'obj'):
          obj = g.obj
      else:
          obj = protect_api(key)
  
      fp = obj.file.storage().open('rb')
  
      # If ImageMagick with Wand is installed, extract first page
      # for PDF/text.
      if HAS_IMAGEMAGICK and obj.mimetype in ['application/pdf', 'text/plain']:
          first_page = Image(Image(fp).sequence[0])
          tempfile_ = tempfile.TemporaryFile()
          with first_page.convert(format='png') as converted:
              converted.save(file=tempfile_)
          return tempfile_
      return fp