Re: Stripping sRGB profile from PNGs in python

2015-07-23 Thread Laura Creighton
To scale images, you should get Pillow, which can construct new images
based on old ones for arbitrary size. see:
http://pillow.readthedocs.org/en/latest/reference/Image.html

Pillow is a fork of PIL.  PIL isn't being maintained, Pillow is.

Note that reading this is a good idea:
http://united-coders.com/christian-harms/image-resizing-tips-every-coder-should-know/

It even has some code that you can probably use, though I haven't tested it.
It just, ah, looks right. :)

Laura

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stripping sRGB profile from PNGs in python

2015-07-23 Thread Emile van Sebille

On 7/23/2015 10:31 AM, Ryan Holmes wrote:

We're getting this error when trying to load some of out projects images:

 libpng warning: iCCP: known incorrect sRGB profile

The source files that we have some with incorrect sRGB profiles. We don't have 
control over the source files, but what we normally do is take them and scale 
them down for our own project. To fix this issue, we can use this shell 
one-liner:

 find . -type f -name "*.png" -exec convert {} {} \;

Which basically converts the ONGs into themselves, but it strips the profile 
(or maybe overwrites with a correct profile).

We would like to incorporate this functionality into our python script which 
scales the source images, but we haven' found a way to do this. Any thoughts?



Use the appropriate shell out command for your python version.  There've 
been too many over the years -- on the system I'm at today running 
Python 2.5 I'm using the commands module.


For example:

commands.getoutput('for ii in /proc/[0-9]*/environ; do echo $ii; strings 
$ii ; done').split()


Emile



--
https://mail.python.org/mailman/listinfo/python-list