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

  • SEARCH
  • Home
  • 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 7039279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:41+00:00 2026-05-28T01:46:41+00:00

I have a png picture, and i need to save it as string, and

  • 0

I have a png picture, and i need to save it as string, and then open it again with PIL. I’m trying to do it like that:

output = StringIO.StringIO()
old_image.save(output, format="PNG")
contents = output.getvalue()
output.close()

new_image = Image.fromstring(contents, "RGBA", old_image.size)

but it gives me an error: TypeError: 'argument 1 must be string without null bytes, not str'

How to solve this problem?

  • 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-28T01:46:42+00:00Added an answer on May 28, 2026 at 1:46 am

    You’ve got the arguments reversed:

    Image.fromstring(mode, size, data, decoder_name='raw', *args)
    

    so

    Image.fromstring("RGBA", old_image.size, contents)
    

    But note that it’s much easier to read from the StringIO object directly:

    output = StringIO.StringIO()
    old_image.save(output, format="PNG")
    
    output.seek(0)
    new_image = Image.open(output)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a link of a picture like that: http://www.google.com/images/srpr/logo3w.png Can I retrieve
I have chart.png with data in it that I would like to put a
I have an base64 picture string in coldfusion. How can I save this image
I have a large png that I would like to use as a background
I have a transparent PNG that is used as a picture frame, and I
I have an image (in .png format), and I want this picture to convert
alt text http://img216.imageshack.us/img216/2288/problem11.png As given in the picture, I have an search bar in
I have a PNG image in an BufferedImage and I would like to lower
I have a PNG file in a UIImageView, and next to that I have
I have a PNG image that has an unsupported bitmap graphics context pixel format.

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.