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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:11:32+00:00 2026-06-17T20:11:32+00:00

Can’t figure out why the document profile is being changed on a crop, scale

  • 0

Can’t figure out why the document profile is being changed on a crop, scale and save with PIL. Have tested with an image that had sRGB as color profile, and after it has untagged RGB.

def scale(self, image):
    images = []

    image.seek(0)

    try:
        im = PIL.open(image)
    except IOError, e:
        logger.error(unicode(e), exc_info=True)

    images.append({"file": image, "url": self.url, "size": "original"})

    for size in IMAGE_WEB_SIZES:
        d = cStringIO.StringIO()
        try:
            im = crop(image, size["width"], size["height"])
            im.save(d, "JPEG")
            images.append({"file": d, "url": self.scale_url(size["name"]), "size": size})
        except IOError, e:
            logger.error(unicode(e), exc_info=True)
            pass

    return images

I am trying to get PIL to save the scaled version with the same colour profile that the original image has.

EDIT: According to this it should be possible http://comments.gmane.org/gmane.comp.python.image/3215, but still not working for me using PIL 1.1.7

  • 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-17T20:11:33+00:00Added an answer on June 17, 2026 at 8:11 pm

    PIL has a function to read the icc_profile and also a way to save with icc_profile. So what I did was to open the file to get the icc_profile:

    try:
        im1 = PIL.open(image)
        icc_profile = im1.info.get("icc_profile")
    

    And the add it to the file again on save:

    im.save(d, "JPEG", icc_profile=icc_profile)
    

    And the full code:

    def scale(self, image):
        images = []
    
        image.seek(0)
    
        try:
            im1 = PIL.open(image)
            icc_profile = im1.info.get("icc_profile")
        except IOError, e:
            logger.error(unicode(e), exc_info=True)
    
        images.append({"file": image, "url": self.url, "size": "original"})
    
        for size in IMAGE_WEB_SIZES:
            d = cStringIO.StringIO()
            try:
                im = crop(image, size["width"], size["height"])
    
                im.save(d, "JPEG", icc_profile=icc_profile)
                images.append({"file": d, "url": self.scale_url(size["name"]), "size": size})
            except IOError, e:
                logger.error(unicode(e), exc_info=True)
                pass
    
        return images
    

    I have tested with both tagged (with icc profile) and untagged jpeg images.

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

Sidebar

Related Questions

Can I order my users in the database, so I don't have to say
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
Can anyone suggest how to underline the title of a UIButton ? I have
Can someone maybe tell me why this is not working? I have used echo
Can I have a project that has some parts written in c and other
Can I prevent an .apk from being installed if unknown sources is checked?
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can you have submenus with the top level set to checkable in WPF? I

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.