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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:25:39+00:00 2026-06-07T07:25:39+00:00

I have a simple Python program that gets artwork from MP3 files. But when

  • 0

I have a simple Python program that gets artwork from MP3 files. But when I try to open the resulting file in my web page, it’s not loaded.

This is my code:

#!"C:/Python32/python.exe"

import binascii
print('Content-type:image/jpeg\n\n\n')


mp3 = r'music.mp3'
mp3_File = open(mp3, "rb")
mp3_Data = mp3_File.read()
mp3_File.close()


hexs = str(binascii.hexlify(mp3_Data))

hexol = []

for ix in range(2, len(hexs)-1, 2):
    hex = hexs[ix]+hex_str[ix+1]
    hexol.append('|'+hex)

hex_str = "".join(hex_list)

img = hexs.split('|41|50|49|43')

p = img[1]
p = p.replace('|','')
p = p[:34*1500]
hexl = []
for ix in range(2, len(p)-1, 2):
    hex = p[ix]+p[ix+1]
    hexl.append(hex)

 art = open('C:\\hi.jpg','wb')
 art.write(binascii.unhexlify(''.join(hexl).encode('utf-8')))
 art.close()
 data = open('C:\\hi.jpg', 'rb').read()
 print(data)
  • 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-06-07T07:25:42+00:00Added an answer on June 7, 2026 at 7:25 am
    • a Windows shebang line? Windows doesn’t understand or use shebang lines

    • it’s usually better to use with to open files (it ensures they get closed again)

    • you do not provide a path to the .mp3 file; are you sure it is in the right directory?

    • it would be clearer if you separated out the ‘get artwork’ stuff as a function, or better yet, use an existing module like mutagen

    • similarly, it is not clear how you are exposing this to a browser; using an existing module like Flask is probably a good solution

    Your code becomes something like

    import mutagen
    from flask import make_response
    import os
    
    music_dir = 'c:/www/music'
    
    @app.route('/cover')
    def cover_art():
        fname = 'music.mp3'
        mp3 = mutagen.File(os.path.join(music_dir, fname))
        art = mp3.tags['APIC:'].data
        def wsgi_app(environ, start_response):
            start_response('200 OK', [('Content-type', 'image/jpeg')])
            return art
        return make_response(wsgi_app)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple python program that I'd like to daemonize. Since the point
Well, i have written a simple python program that parses HTML with HTMLParser. Here
I have a very simple python script that should scan a text file, which
Simple case I have a Python program that I intend to support on both
I have a python program that I would like to present as a simple
I have a very very simple program that parses a csv file that has
I want to have simple program in python that can process different requests (POST,
I have been trying to create a simple program with Python which uses OpenCV
I have a simple Python script that uses the socket module to send a
I have the following simple python test script that uses Suds to call a

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.