title: PIL.UnidentifiedImageError: cannot identify image file
body: <p>I'm working on GCP cloud functions and intend to write a functions which combines two images. But I', getting the following error when I invoke the function: </p>
  
  <blockquote>
    <p>Traceback (most recent call last): File
    "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py",
    line 346, in run_http_function result =
    _function_handler.invoke_user_function(flask.request) File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py",
    line 217, in invoke_user_function return
    call_user_function(request_or_event) File
    "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py",
    line 210, in call_user_function return
    self._user_function(request_or_event) File "/user_code/main.py", line
    74, in execute newIntro= generateIntroImage(nameMappings['stdName'],
    nameMappings['stdPicture'], nameMappings['logo'],
    nameMappings['stdYear'], nameMappings['font']) File
    "/user_code/main.py", line 12, in generateIntroImage
    images.append(Image.open(logo)) File
    "/env/local/lib/python3.7/site-packages/PIL/Image.py", line 2862, in
    open "cannot identify image file %r" % (filename if filename else fp)
    PIL.UnidentifiedImageError: cannot identify image file '/tmp/logo.jpg'</p>
  </blockquote>
  
  <p>I have ran this function on my local machine and it works as expected but when I deploy it on GCP, it gives this error and crashes. Here's my function:</p>
  
  <pre><code>from PIL import Image
  from PIL import ImageFont
  from PIL import ImageDraw
  
  def generateIntroImage(stdName, stdPicture, logo, year, typeFace):
      images = [Image.open(x) for x in [stdPicture, logo]]
      widths, heights = zip(*(i.size for i in images))
      total_width = sum(widths)
      max_height = max(heights)
      new_im = Image.new('RGB', (total_width, max_height))
      x_offset = 0
      for im in images:
          new_im.paste(im, (x_offset,0))
          x_offset += im.size[0]
  
      font= ImageFont.truetype(typeFace, 70)
      draw= ImageDraw.Draw(new_im)
      draw.text((0, 0), stdName+"'s " +year+" Year Book", (0,0,0),font= font)
      fileName= "/tmp/test.jpg"
      new_im.save(fileName)
      return fileName
  </code></pre>
  
  <p>These images are .jpg and .png files. Any idea what could be wrong?</p>