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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:28:45+00:00 2026-05-15T16:28:45+00:00

I want to convert the input 24 bit PNG image to 8 bit, I

  • 0

I want to convert the input 24 bit PNG image to 8 bit, I have tried using Imagemagick and Python PIL, neither works.

for instance:

at Imagemagick I try convert console command as such:

convert -depth 8 png24image.png png8image.png

And here is the way I tried with python:

import Image
def convert_8bit(src, dest):
    """
    convert_8bit: String, String -> void.
    Converts the input image file into 8bit depth.
    """
    im = Image.open(src)
    if not im.mode == "P":
        im2 = im.convert("P", rgb2xyz)
        im2.save(dest)

Imagemagick doesn’t even touch the image while the python function reduces to 8bit but keeps the number of unique numbers 164instead of 256. Photoshop used to convert the image to 8bit with 256unique numbers when converted to png8 from a 24 bit png image.

Thanks

EDIT:

Output of 24->8 png conversion via Photoshop (which I need)
alt text http://img695.imageshack.us/img695/934/psout.png

Converted via my Python function

alt text http://img638.imageshack.us/img638/6762/pythonout.png

  • 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-15T16:28:46+00:00Added an answer on May 15, 2026 at 4:28 pm

    It looks like the quantization method on the convert method isn’t doing the right thing. Try this:

    im2 = im.convert('RGB').convert('P', palette=Image.ADAPTIVE)
    

    The extra conversion to RGB may be redundant. I got this hint from http://nadiana.com/pil-tips-converting-png-gif

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

Sidebar

Related Questions

I want to convert plaintext to link for an input I have. The HTML
I have a script that accepts XML input, and I want to convert it
I have the input 15:20:30 I want to convert to seconds.
I found this command Resize an image with improved quality: $ convert input.png -colorspace
I want to convert words into tags. So for example I have an input,
I'm using ffmpeg to convert .avi file into a .png image sequence. This one
I want to convert a string input like 2,3,6,7,8,10,12,14,15,16 to 2-3,6-8,10,12,14-16 using java I
I want to convert a 44,100 Hz, 24 Bit Mono wav file to aformat
I want to convert a large 64 bit value from decimal or hex string
I want to convert an integer to binary string and then store each bit

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.