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 6217563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:26:57+00:00 2026-05-24T07:26:57+00:00

I want to convert some base64 encoded png images to jpg using python. I

  • 0

I want to convert some base64 encoded png images to jpg using python. I know how to decode from base64 back to raw:

import base64 
pngraw = base64.decodestring(png_b64text)

but how can I convert this now to jpg? Just writing pngraw to a file obviously only gives me a png file. I know I can use PIL, but HOW exactly would I do it? Thanks!

  • 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-24T07:26:57+00:00Added an answer on May 24, 2026 at 7:26 am

    You can use PIL:

    data = b'''iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAIBJRE
              FUOMvN08ENgCAMheG/TGniEo7iEiZuqTeiUkoLHORK++Ul8ODPZ92XS2ZiADITmwI+sWHwi
              w2BGtYN1jCAZF1GMYDkGfJix3ZK8g57sJywteTFClBbjmAq+ESiGIBEX9nCqgl7sfyxIykt
              7NUUD9rCiupZqAdTu6yhXgzgBtNFSXQ1+FPTAAAAAElFTkSuQmCC'''
    
    import base64
    from PIL import Image
    from io import BytesIO
    
    im = Image.open(BytesIO(base64.b64decode(data)))
    im.save('accept.jpg', 'JPEG')
    

    In very old Python versions (2.5 and older), replace b''' with ''' and from io import BytesIO with from StringIO import StringIO.

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

Sidebar

Related Questions

For some complicated reason, I want to convert any supported type T (coming from
I want to create a program to convert some music files from wav to
recently i want to convert some codes from opencv to c#. But I have
I want to convert date from one format to another.Let's say, I have some
I want to convert some text from utf-8 to iso-8859-1 (in PHP) so I
I'm trying to convert some data from long to wide using the reshape2 package,
I want to convert a string into a double and after doing some math
I have some html files that I want to convert to text. I have
I want some particular urls like springer.com to automatically convert to springer.com.proxy1.mycollege.edu. The second
I'm wanted to convert some of my python code to C++ for speed but

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.