Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:49:22+00:00 2026-05-22T20:49:22+00:00

I am using PIL (Python Imaging Library), and Paste to make a very simple

  • 0

I am using PIL (Python Imaging Library), and Paste to make a very simple web page. I have a function that returns just an image tag:

def home(self):
    return '<img src="photo" alt="photo"/>'

And I also have a function called photo that (ideally) returns the image to be put in the img tag:

def photo(self):
    img = image_from_PIL # this part works
    output = StringIO.StringIO()
    img.save(output, "JPEG") # saves the image as a StringIO in output
    final_img = output.getvalue()
    output.close()

    # then set headers['content-type'] = 'image/jpeg' (confirmed this works)

    return [final_img]

So I know that the image exists in the string final_img and that the content-type is “image/jpeg”. I’d expect this to work, but all I get is a 200 status OK reponse of size 0.

I tried many other things too including:

  • Converting the string to binary and spitting that out
  • Setting the content-length in the header to the length of the string (and x8 since each char is 8 bits)

If it makes any difference, my server is using uWSGI and nginx

I don’t know what else to try! Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:49:22+00:00Added an answer on May 22, 2026 at 8:49 pm

    Do not return a list with the image, but the image itself.

    Replace

    return [final_img]
    

    with

    return final_img
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the PIL (python image library) to crop a very large image
I am using the Python Imaging Library to colorize a black and white image
I am using Tesseract OCR (via pytesser ) and PIL (Python Image Library) for
I've got a Python program using PIL to render text, and it works great
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using PIL in python one must put the full directory for an image, so
I want to do some image processing using Python. Is there a simple way
I'm building a small web project using Django that has one model ( Image
I had been using using PIL but I just found out that it doesn't
I have a view in my Django application that automatically creates an image using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.