Mac support for PIL

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Mac support for PIL

Paul Ross-2
Hi there and I'm sorry to bother you but...

I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon?

I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG.

I have googled for the answer for a couple of hours now and tried many ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I always just get "IOError: decoder jpeg not available" whenever I try and manipulate JPEG images

Many thanks if you can help me hack PIL to build on a Mac!

Paul.
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

Yury V. Zaytsev
Hi!

On Wed, 2010-05-05 at 21:42 +0100, Paul Ross wrote:
>
> I know that PIL is Windows-centric but is there any chance that it will
>  support Snow Leopard on Apple Mac some time soon?

Windows-centric?!

> I have googled for the answer for a couple of hours now and tried many
>  ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I
>  always just get "IOError: decoder jpeg not available" whenever I try
>  and manipulate JPEG images

Basically you have to build and install libjpeg and other decoders from
source or use a package management system, such as Fink or Macports,
then rebuild PIL against them.

If you want more help, ask specific questions.

--
Sincerely yours,
Yury V. Zaytsev

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

Fredrik Lundh
In reply to this post by Paul Ross-2
Do you have the necessary support libraries on your machine?  (see the
README file).

There are prebuilt versions out there too; maybe some Mac hackers can
chime in and point you to the latest and greatest.

</F>

On Wed, May 5, 2010 at 10:42 PM, Paul Ross <[hidden email]> wrote:

> Hi there and I'm sorry to bother you but...
>
> I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon?
>
> I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG.
>
> I have googled for the answer for a couple of hours now and tried many ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I always just get "IOError: decoder jpeg not available" whenever I try and manipulate JPEG images
>
> Many thanks if you can help me hack PIL to build on a Mac!
>
> Paul.
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

jalopyuser
In reply to this post by Paul Ross-2
Paul Ross <[hidden email]> wrote:

> Hi there and I'm sorry to bother you but...
>
> I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon?
>
> I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG.

Works for me.  I build libjpeg, libpng, libfreetype, etc. from source
first, and install them, then build PIL.  Haven't tried it with 10.6.3,
though.

You have to edit the PIL setup.py file, and put the paths to the library
directories in it, though, before building PIL.

Bill
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

Adrian Price-Whelan-2
I'm using Snow Leopard version 10.6.3 - I didn't have to do any hacks to get it working once I had the necessary dependancies installed.

--
Adrian Price-Whelan
http://cosmo.nyu.edu/~apw235

On May 7, 2010, at 12:19 PM, Bill Janssen wrote:

> Paul Ross <[hidden email]> wrote:
>
>> Hi there and I'm sorry to bother you but...
>>
>> I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon?
>>
>> I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG.
>
> Works for me.  I build libjpeg, libpng, libfreetype, etc. from source
> first, and install them, then build PIL.  Haven't tried it with 10.6.3,
> though.
>
> You have to edit the PIL setup.py file, and put the paths to the library
> directories in it, though, before building PIL.
>
> Bill
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

Chris Barker
In reply to this post by Fredrik Lundh
Fredrik Lundh wrote:
> Do you have the necessary support libraries on your machine?  (see the
> README file).
>
> There are prebuilt versions out there too; maybe some Mac hackers can
> chime in and point you to the latest and greatest.

I'd ask on the pyhthonmac SIG list. Maybe someone there has or will
produce a binary ( I have NO time for it right now! )

If you do want to do it yourself, the easiest way to get the libs is
macports.

Bill Janssen wrote:
> Works for me.  I build libjpeg, libpng, libfreetype, etc. from source
> first, and install them, then build PIL.  Haven't tried it with 10.6.3,
> though.

Bill,

any chance you could put together a binary installer -- it would be a
nice service to the community.

-Chris



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

Paul Ross-2
In reply to this post by Yury V. Zaytsev
Thanks, and sorry, what I meant to say is that PIP is really easy to install on windows but a bit of a trial on Mac.

There are loads of blog entries around, which perhaps reflects the trouble that people are having. Many of these entries are highly version specific and have a less than unity probability of success (I tried three before I managed to get things working). Judging by the comment on most blogs other people are in the same boat as I.

FWIW this is what eventually worked for me:
Based on: http://rezmuh.sixceedinc.com/2009/04/setting-up-pil-with-libjpeg-on-mac-os-x-leopard.html

I got and installed MacPorts-1.8.2-10.6-SnowLeopard.dmg from:
http://distfiles.macports.org/MacPorts/

Then in Imaging-1.1.7:

In setup.py  changed the JPEG_ROOT to:
JPEG_ROOT = "/opt/local/lib/libjpeg.dylib"

Then:
sudo python setup.py build --force
sudo python setup.py install

I would not guarantee this will work for others!

Thanks for the help and thanks for such a great product as PIL

Regards,

Paul.

FWIW I s
On 7 May 2010, at 16:05, Yury V. Zaytsev wrote:

> Hi!
>
> On Wed, 2010-05-05 at 21:42 +0100, Paul Ross wrote:
>>
>> I know that PIL is Windows-centric but is there any chance that it will
>> support Snow Leopard on Apple Mac some time soon?
>
> Windows-centric?!
>
>> I have googled for the answer for a couple of hours now and tried many
>> ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I
>> always just get "IOError: decoder jpeg not available" whenever I try
>> and manipulate JPEG images
>
> Basically you have to build and install libjpeg and other decoders from
> source or use a package management system, such as Fink or Macports,
> then rebuild PIL against them.
>
> If you want more help, ask specific questions.
>
> --
> Sincerely yours,
> Yury V. Zaytsev
>

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: Mac support for PIL

jalopyuser
Here's the fragment of my csh script which builds PIL.  I unpack PIL, libpng,
libjpeg, libfreetype, and libtiff in a directory, then build them with
this.  Note that the key in building PIL is to replace the reference to "/sw"
with the pointer to where you want to install it, in this example "/usr/local".
You may need to run this as sudo, depending on what else you've done to your
Python installation -- this one's keyed to the standard /usr/bin/python.

Bill

================================================================================

setenv distdir /usr/local

cd libpng-*
./configure --prefix=${distdir}
make
make install

cd ../jpeg*
./configure --prefix=${distdir}
make
make install
make install-lib
make install-headers
ranlib ${distdir}/lib/libjpeg.a

setenv CPPFLAGS "-I${distdir}/include"
setenv LDFLAGS "-L${distdir}/lib"
setenv CXXFLAGS "-I${distdir}/include"

cd ../tiff-*
./configure --prefix=${distdir} --without-x
make
make install

cd ../freetype-2.*
# first, get rid of erroneous mac flag
cp include/freetype/config/ftconfig.h /tmp/build-mac-uplib-tmp-$$
rm -f include/freetype/config/ftconfig.h
sed -e 's/#define FT_MACINTOSH 1/#undef FT_MACINTOSH/' < /tmp/build-mac-uplib-tmp-$$ > include/freetype/config/ftconfig.h
# next, enable the bytecode interpreter
rm -f /tmp/build-mac-uplib-tmp-$$
cp include/freetype/config/ftoption.h /tmp/build-mac-uplib-tmp-$$
rm -f include/freetype/config/ftoption.h
sed -e 's;/\* #define  TT_CONFIG_OPTION_BYTECODE_INTERPRETER \*/;#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER;' < /tmp/build-mac-uplib-tmp-$$ > include/freetype/config/ftoption.h
# now build
./configure --prefix=${distdir}
make
make install
cp ${distdir}/include/ft2build.h ${distdir}/include/freetype2/

cd ../Imaging-1.1.*
rm -f /tmp/build-mac-uplib-tmp-$$
cp setup.py /tmp/build-mac-uplib-tmp-$$
sed -e "s;/sw;${distdir};" < /tmp/build-mac-uplib-tmp-$$ > setup.py
/usr/bin/python setup.py build
/usr/bin/python setup.py install

================================================================================
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig