[Image-SIG] Resampling with antialiasing while using only 8 greyscales

2013-06-25 Thread Paul Furley
Good evening,

F
irstly, thanks for creating and maintaining such a fantastic library, the
PIL is awesome!

I've got an interesting problem and I'd really appreciate if someone could
point me in the right direction. I'm a reasonable developer but I've become
out of my depth in image science :)

I've got greyscale images which I have dithered (Floyd-Steinberg) so that
they contain exactly 8 shades. The pixel values present in the images are 0,
36, 73, 109, 146, 182, 219, 255 - so 8 levels with pure-white and
pure-black being represented. Naturally, most of the 256 possible pixel
values in the histogram are empty.

I want to reduce the size of this image by 3x in both directions, ie (300,
300) => (100, 100) *with* anti-aliasing but *without* creating pixels
outside of those 8 shades. Of course, the Lanczos implementation in PIL
doesn't know to only use values 0, 36, 73 etc, so it uses the full 256
range, thereby undoing my dithering work.

Can anyone suggest a good approach to this? Would it be possible to modify
the resampling algorithm to work in 8 shades rather than 256? Or is there a
way I could put the pixel values back into the 8 "buckets" afterwards
without wrecking the colour accuracy? I have tried the latter and gradients
become steps, as you'd expect. It doesn't seem right to apply dithering
again somehow.

I have considered re-ordering my process from:
*High-res image -> Dithering -> Resampling*

to

*High-res image -> Resampling -> Dithering*

but I then think the dithering process wreaks havoc on the beautifully
antialiased edges in the image.

Any thoughts would be very gratefully received.

Kind regards,
Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] [SPAM] - Re: fromarray rotates image - Email found in subject

2012-02-04 Thread Cousoulis, Paul
The second image is a 32 bit tif, so you need to use something like ImageJ or 
Fiji. Microsoft image viewer won't work. I think I shouldn't have to fiddle 
with the row/column order, but I guess  it needs to stay the way it is. Thanks 
for the help.

Paul

-Original Message-
From: Chris Barker [mailto:chris.bar...@noaa.gov] 
Sent: Tuesday, January 31, 2012 1:18 PM
To: Cousoulis, Paul; image-sig@python.org
Subject: [SPAM] - Re: [Image-SIG] fromarray rotates image - Email found in 
subject



On Tue, Jan 31, 2012 at 8:38 AM, Cousoulis, Paul  
wrote:
> I'm sorry but I still think there is a bug.

I still don't think so: explanation below.

By the way, there is another problem with your example -- I get an all-black 
second image. I think you need to specify the image mode when you create the 
new image:

newimage = Image.fromarray(npArray, mode=image1.mode)

though that still makes a mess of it! -- more debugging to be done here -- see 
below

> In [4]: print image1.size
> (516, 356)
>
> In [5]: npArray = np.array(image1.getdata())
>
> In [6]: print npArray.shape
> (183696L,)

OK so far


> In [7]: npArray.shape = image1.size

> In [8]: print npArray.shape
> (516L, 356L)

here I would swap -- as numpy naturally stores data the other way:

and now it works:

In [8]: run pil-numpy-test.py
 
input image size: (516, 356) numpy image shape before: (183696,) numpy image 
shape after: (356, 516)  new image size (516, 356)

(though the colors are still screwed up -- I don't know what's up with that...)

I can see how you'd expect it to work the way you had it, but I think the 
problem is that you are mixing two ways to push raw data to/froim numpy arrays:

npArray = np.array(image1.getdata())

is using PIL's getdata() to put the raw data in a string, then turning that 
into a numpy array (oh, and that may be the source of teh data mess up 
too...np.array is expecting a sequence of numbers or something, not raw data -- 
you want:

OOPS, actually, getdata returns something else altogether:

"""
getdata

im.getdata() => sequence

Returns the contents of an image as a sequence object containing pixel values. 
The sequence object is flattened, so that values for line one follow directly 
after the values of line zero, and so on.

Note that the sequence object returned by this method is an internal PIL data 
type, which only supports certain sequence operations, including iteration and 
basic sequence access. To convert it to an ordinary sequence (e.g. for 
printing), use list(im.getdata()).
"""
so it should be:

npArray = np.fromstring(image1.tostring(), dtype=np.uint8)

npArray.shape = (image1.size[1], image1.size[0] )

and that now works -- correct size, and correct final image.

However:

newimage = Image.fromarray(npArray)

is using the numpy "array protocol", which is a bit different than 
fromstring/tostring -- it carries shape information -- hence the need to 
specify the shape of the numpy array as I did.

you can use that protocol both ways:

npArray = np.asarray(image1)

which then preserved size info.

Here's my new version:

from PIL import Image
import numpy as np


image1 = Image.open("LineGraph.tif")
print image1
print "input image size:", image1.size

npArray = np.asarray(image1)

print "numpy image shape after:", npArray.shape

newimage = Image.fromarray(npArray, mode=image1.mode)

print newimage
print "new image size", newimage.size

newimage.save("LineGraph2.tif")


NOTE: if you do fromstring/tostring (or tobuffer) consistently, then it doesn't 
matter what shape you make the numpy array:


image1 = Image.open("LineGraph.tif")
print image1
print "input image size:", image1.size

npArray = np.fromstring(image1.tostring(), dtype=np.uint8)

print "numpy image shape:", npArray.shape

newimage = Image.fromstring(image1.mode, image1.size, npArray.tostring())

print newimage
print "new image size", newimage.size

newimage.save("LineGraph2.tif")

But that's less efficient, and messier.

NOTE: it might have been nicer if the array protocol were used such that the 
array created was fortran-order, and thus (w,h) in shape, but so it goes.

HTH,

   -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

chris.bar...@noaa.gov


== 
 This electronic message transmission and any attachments are 
 confidential and/or proprietary and may constitute legally privileged 
information of 
 Meso Scale Diagnostics, LLC. The information is intended for solely 
 the use of recipient (recipient).  If you are not 
 the intended recipient, yo

[Image-SIG] fromarray rotates image

2012-01-29 Thread Cousoulis, Paul
The fromarray method is rotating the shape of arrays when converting from numpy 
arrays.

In [56]: npArray.shape
Out[56]: (650, 670)

In [57]: newimage = Image.fromarray(npArray)

In [58]: newimage.size
Out[58]: (670, 650)

In [59]: Image.VERSION
Out[59]: '1.1.7'

Thanks
Paul


==
 This electronic message transmission and any attachments are
 confidential and/or proprietary and may constitute legally privileged 
information of
 Meso Scale Diagnostics, LLC. The information is intended for solely
 the use of image-sig@python.org (image-sig@python.org).  If you are not
 the intended recipient, you are hereby notified that any
 disclosure, copying, distribution or the taking of any action in
 reliance of this information is strictly prohibited. You are not
 authorized to retain it in any form nor to re-transmit it, and
 you should destroy this email immediately.

 If you have received this electronic transmission in error,
 please notify us by telephone (240-631-2522) or by electronic
 mail to the sender of this email, Cousoulis, Paul (pcousou...@meso-scale.com),
 immediately.
 =


___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] PIL does not support iTXt PNG chunks [patch]

2011-12-04 Thread Paul Sladen
(Forwarded from:  http://bugs.python.org/issue13514  per Ezio Melotti)

The Python Imaging Library does not support handling of UTF-8 'iTXt'
key:value chunks in PNG files:

  http://www.w3.org/TR/PNG/#11iTXt

Such support is necessary for successful extraction of key:value pairs
of UTF-8 encoded data, stored in an PNG 'iTXt' comment chunk.

The following example file (from British GCHQ) demonstrates such a
record in a PNG file.  Based on this evidence, it is highly likely
that GCHQ hide all of their important secrets using this kind of
steganography, and likely necessary that spies from the rest of the
world are requiring similar access to GCHQ secrets.  Inclusion of a
working chunk_iTXt() PIL/PNG support function will enable more
harmonious and effective eavesdropping.  Example image:

  http://www.canyoucrackit.co.uk/images/cyber.png

(The attached .py file is not a directly apply-able patch, but
contains a working implementation for chunk_iTXt() and a demonstrative
test function for inserting it).

-Paul

#!/usr/bin/env python
# Paul Sladen, 2011-12-01
from PIL import PngImagePlugin, Image, ImageFile
#Image.DEBUG = True

# Meh, why doesn't PIL support this already?
def chunk_iTXt(self, pos, len):
s = ImageFile._safe_read(self.fp, len)
# http://www.w3.org/TR/PNG/#11iTXt
k, structure = s.split('\0', 1)
compression_flag, compression_method = map(ord, structure[:2])
language_tag, translated, t = structure[2:].split('\0', 2)
if compression_flag == 0:
v = t.decode('utf-8')
elif compression_flag == 1 and compression_method == 0:
import zlib
v = zlib.decompress(t).decode('utf-8')
else:
raise SyntaxError("Unknown compression request %d in iTXt chunk" %
  compression_method)
self.im_info[k] = {'translated_keyword': translated.decode('utf-8'),
   'language_tag': language_tag,
   'text': v}
self.im_text[k] = v
return s

PngImagePlugin.PngStream.chunk_iTXt = chunk_iTXt

def test(f):
i = PngImagePlugin.PngImageFile(f)
print i.info, i.text
steno = i.text['Comment'].decode('base64')

if __name__ == '__main__':
test('cyber.png')
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Mac support for PIL

2010-05-08 Thread Paul Ross
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  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Mac support for PIL

2010-05-07 Thread Paul Ross
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  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] PIL 1.1.7 binary for python 2.4

2009-11-13 Thread Paul
Hi Fredrik,

I'm using PIL to do some quick image manipulation and I'm very happy with
it.
I would like to use the chroma subsampling that is present in PIL 1.1.7, but
I'm restricted to use Python 2.4... Could you point me out where I can find
a Windows binary of PIL 1.1.7 for Python 2.4?

Thanks!

Best regards,

Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] ImageFont family mojibake

2009-09-16 Thread Paul Moore
2009/9/16 Donn :
> Thanks to Stani for letting me know I did reach the list. Seems I disabled my
> receiving of email from the list a while back and I forgot about it.
>
> I will get mail from now on, but am not sure if anyone weighed-in on the OP.
> Is there any feedback? If so, is there a link to the archives somewhere?
>
> Thanks, sorry for the noise.
> \d

I've seen 3 mails from you and no replies. Looks like nobody's been
able to help.
Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] ImageFont family mojibake

2009-09-16 Thread Paul Moore
2009/9/16 Donn :
> Another ping. Is anyone seeing the OP?
> \d

I see it. Just can't help...
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] ImageTk.PhotoImage: DLL load failed: The specified module could not be found.

2009-07-09 Thread Jean-Paul Miéville
Hello,

I have an problem with ImageTk.PhotoImage.

When I try to use it with for example with the following script:

import ImageTk
import Image
import tkFileDialog
imgFile = tkFileDialog.askopenfilename()
if imgFile:
    image = Image.open(imgFile)
    chart = ImageTk.PhotoImage(image)

I got the following error:

Traceback (most recent call last):
  File "C:\Python\PythonScript\Test\Script1.py", line 9, in 
    chart = ImageTk.PhotoImage(image)
  File "C:\Python25\Lib\site-packages\PIL\ImageTk.py", line 116, in __init__
    self.paste(image)
  File "C:\Python25\Lib\site-packages\PIL\ImageTk.py", line 181, in paste
    import _imagingtk
ImportError: DLL load failed: The specified module could not be found.
The file _imagingtk is present in the path C:\Python25\Lib\site-packages\PIL\.

I don't understand what is wrong. I am using ActivePython 2.5.4.4
(ActiveState Software Inc.)base on Python 2.5.4 (r254:67916, Apr 27
2009, 15:41:14).

Thanks for your help,

Jean-Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] ImageTk.PhotoImage: DLL load failed: The specified module could not be found.

2009-07-09 Thread Jean-Paul Miéville
Hello,

I have an problem with ImageTk.PhotoImage.

When I try to use it with for example with the following script:

import ImageTk
import Image
import tkFileDialog

imgFile = tkFileDialog.askopenfilename()
if imgFile:
image = Image.open(imgFile)
chart = ImageTk.PhotoImage(image)

I got the following error:
Traceback (most recent call last):
  File "C:\Python\PythonScript\Test\Script1.py", line 9, in 
chart = ImageTk.PhotoImage(image)
  File "C:\Python25\Lib\site-packages\PIL\ImageTk.py", line 116, in __init__
self.paste(image)
  File "C:\Python25\Lib\site-packages\PIL\ImageTk.py", line 181, in paste
import _imagingtk
ImportError: DLL load failed: The specified module could not be found.

The file _imagingtk is present in the
path C:\Python25\Lib\site-packages\PIL\.

I don't understand what is wrong. I am using ActivePython 2.5.4.4
(ActiveState Software Inc.)base on Python 2.5.4 (r254:67916, Apr 27 2009,
15:41:14).

Thanks for your help,

Jean-Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Resizing Photos

2009-04-23 Thread Paul Johnston
Hi,

Scratch that - I found the ANTIALIAS mode and the thumbnails are now much
better quality.

Thanks for a great lib!

Paul


On Tue, Apr 21, 2009 at 9:11 AM, Paul Johnston  wrote:

> Hi,
>
> I'm currently using PIL to resize photos down to a thumbnail. Something
> I've noticed though, is that whatever software Facebook use too do the same,
> produces better-quality thumbnails.
>
> Are there any tweaks I can apply to PIL to get better resizing? Or any idea
> what software FB may be using?
>
> Paul
>
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Resizing Photos

2009-04-22 Thread Paul Johnston
Hi,

I'm currently using PIL to resize photos down to a thumbnail. Something I've
noticed though, is that whatever software Facebook use too do the same,
produces better-quality thumbnails.

Are there any tweaks I can apply to PIL to get better resizing? Or any idea
what software FB may be using?

Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] PIL 1.1.6 and convert cmyk jpegs to rgb and writing png files

2009-03-03 Thread Paul Egan
Just in case this CMYK patch does make it into the PIL svn repo...
there's a small bug: before calling invert, self.im should be checked.
This is necessary because the ImageFile.Parser.feed method tries an 
open() to see if the image is complete.

Attached is an updated patch.
Index: PIL/JpegImagePlugin.py
===
--- PIL/JpegImagePlugin.py	(revision 460)
+++ PIL/JpegImagePlugin.py	(working copy)
@@ -1,6 +1,6 @@
 #
 # The Python Imaging Library.
-# $Id: JpegImagePlugin.py 2763 2006-06-22 21:43:28Z fredrik $
+# $Id: JpegImagePlugin.py 2199 2004-12-18 08:49:05Z fredrik $
 #
 # JPEG (JFIF) file handling
 #
@@ -32,7 +32,7 @@
 __version__ = "0.5"
 
 import array, string
-import Image, ImageFile
+import Image, ImageFile, ImageChops
 
 def i16(c,o=0):
 return ord(c[o+1]) + (ord(c[o])<<8)
@@ -270,8 +270,11 @@
 handler(self, i)
 if i == 0xFFDA: # start of scan
 rawmode = self.mode
-if self.mode == "CMYK":
-rawmode = "CMYK;I"
+# patch by Kevin Cazabon to comment this out - nobody should be using Photoshop 2.5 any more (and it breaks newer versions)
+# CMYK images are still inverted, we'll fix that just before returning.
+#if self.mode == "CMYK" and self.info.has_key("adobe"):
+#rawmode = "CMYK;I" # Photoshop 2.5 is broken!
+
 self.tile = [("jpeg", (0,0) + self.size, 0, (rawmode, ""))]
 # self.__offset = self.fp.tell()
 break
@@ -282,6 +285,10 @@
 else:
 raise SyntaxError("no marker found")
 
+# patch by Kevin Cazabon to re-invert CMYK JPEG files
+if self.im and self.mode == "CMYK":
+self.im = ImageChops.invert(self).im
+
 def draft(self, mode, size):
 
 if len(self.tile) != 1:
@@ -378,7 +385,7 @@
 "RGB": "RGB",
 "RGBA": "RGB",
 "RGBX": "RGB",
-"CMYK": "CMYK;I",
+"CMYK": "CMYK",
 "YCbCr": "YCbCr",
 }
 
@@ -406,6 +413,10 @@
 dpi[0], dpi[1]
 )
 
+if im.mode == "CMYK":
+# invert it so it's handled correctly in Photoshop/etc. - Kevin Cazabon.
+im = ImageChops.invert(im)
+
 ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
 
 def _save_cjpeg(im, fp, filename):
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Font colour.

2007-04-26 Thread Paul Svensson
On Thu, 26 Apr 2007, Amos Newcombe wrote:

> You find the complementary color by subtracting each color band from 255
> (assuming 8-bit color). The problem with this is that if your original color
> is medium gray, the complementary color will be very close to it and you
> will get no legibility. So you have to test for this case and go to some
> other color, perhaps black or white.

Slightly better than complementing each color band, set it as far off
from the background as you can; [00..7F] -> FF, [80..FF] -> 00.

/Paul

> Amos
>
> On 4/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> 
>> Christopher ,
>> Thank you for your reply.
>> 
>> Is there a way how to find out a complementary colour for an area where I
>> will write the text, so
>> that the text will be seen clearly?Is there a routine in PIL or in Python
>> somewhere?
>> Thank you for help
>> Lad.
>> 
>

-- 
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] PIL on a Mac

2007-04-25 Thread Paul Rigor

I sent a how-to using finkl as a sandbox to perform the installation.
However, it was never sent through.  Why?

On 4/24/07, Bill Janssen <[EMAIL PROTECTED]> wrote:


> It does, but it's an old version

But not significantly different from the current version in most
respects, certainly for a beginner.  I've built and still use large
complicated apps with lots of external Python libraries that run just
fine on the system Python.

> and somewhat broken in some subtle ways.

Too subtle to be interesting.

Bill
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig





--
http://covertheuninsured.org/
http://www.nrdcaction.org/gwtakeaction
http://www.nrdcactionfund.org/tellafriend.asp
http://www.savetheinternet.com
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] PIL on a Mac

2007-04-25 Thread Paul Rigor

I sent a how-to using finkl as a sandbox to perform the installation.
However, it was never sent through.  Why?

On 4/24/07, Bill Janssen <[EMAIL PROTECTED]> wrote:


> It does, but it's an old version

But not significantly different from the current version in most
respects, certainly for a beginner.  I've built and still use large
complicated apps with lots of external Python libraries that run just
fine on the system Python.

> and somewhat broken in some subtle ways.

Too subtle to be interesting.

Bill
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig





--
http://covertheuninsured.org/
http://www.nrdcaction.org/gwtakeaction
http://www.nrdcactionfund.org/tellafriend.asp
http://www.savetheinternet.com
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] PIL on a Mac

2007-04-24 Thread Paul Rigor

Hi,

You should checkout http://www.finkproject.org/ which creates a 'sandbox'
for gnu/unix/non-mac utilities.  It comes with a GUI which lets you select
packages from their repository (similar to a yum/apt-get repository for
several linux distributions out there).  It also comes with command-line
tools, if you prefer.

Once you've installed fink and python, you can directly call the python
binary installed in the fink default bin (eg, /sw/bin/) when using the setup
tools (eg, setup.py) which comes with PIL.  Using this fink 'python' will
install the PIL package inside python's corresponding site-packages folder.


In order to set the fink environment automatically every time you use the
terminal, you'll need to modify your .bash_profile. Add the following line
"test -r /sw/bin/init.sh && . /sw/bin/init.sh".  You'll of course need to
adapt the fink installation path as you see fit.

Good luck,
Paul

On 4/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Hello Support,
I'm sitting here looking at the ReadMe for the PIL, and I realized
something a few moments back: this is more complicated than I thought it
would be. If it isn't too difficult, would you be able to tell me how I
could put the PIL in my computer so I can just play around with Python and
images. I am currently in a introductory course to computer science and we
are using Python. I am running it on a MacBook Pro right now. I guess I
had to download a MacPython in order to make Python work on my system. I'm
not too sure, but it does seem to work. The problem that I'm having now
seems to be stemming from his "Imaging-1.1.6" folder that I just
downloaded. What should I do with it? I was looking at the ReadMe (that's
where I got this e-mail) and it says that I'll need to download more
things (correct?). My professor did say something about Fink.
Now, I don't want you guys to go totally out of your way because there is
a computer lab on campus that I could do all this on, but I would like it
to be on my computer, too, just so I can finish the homework up and play
around with image transformations.
Thank you.
Adam Crouse

___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig





--
http://www.nrdcaction.org/gwtakeaction
http://www.nrdcactionfund.org/tellafriend.asp
http://www.savetheinternet.com
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Crack Code?

2007-03-13 Thread Paul Rigor

Hi,

Whatever happened to the PIL module CrackCode??  PIL plus is no longer
available either.

Thanks,
Paul

--
http://www.nrdcactionfund.org/tellafriend.asp
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] CrackCode

2007-03-13 Thread Paul Rigor

Hi,

Whatever happened to the CrackCode PIL module?

Thanks,
Paul
--
http://www.nrdcactionfund.org/tellafriend.asp
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] xpm files not supported

2007-03-13 Thread Paul Rigor

Hi all,

There was an old post regarding xpm compatibility.  I was wondering whether
the latest development version has incorporated this users suggestions?

http://mail.python.org/pipermail/image-sig/2006-October/004159.html

I'm currenly using 1.1.6 and the suggested fixes haven't been incorporated
yet.  Are there any plans on doing so?

Thanks,
Paul

--
http://www.nrdcactionfund.org/tellafriend.asp
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Newb help... can't install the PIL extension libraries

2007-01-25 Thread Paul
Hi,

 

I'm very new to linux (2 days!) but have been using Python on windows
for a few weeks now. I would like to install PIL on my linux (ubuntu)
machine but am having all sorts of trouble following the readme, I get a
ton of errors when trying to run the build.py. Mostly cannot find
directory errors, but there are others thrown in for good measure.

 

This is my first attempt at importing a library within linux.

 

I unzipped the tar file into my user space...

 

/home/paul/Python/ExtensionLibraries

 

which I created myself. This is where I'm going wrong I presume. The
readme said that I could create my own directory, so I'm confused.

 

Should I unzip it & build it somewhere else?

 

Any help greatly appreciated, many thanks.

 

PMF

___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] PIL Programming Questions

2006-08-18 Thread Paul Prescod
I just finished a PIL program and I feel like there may have been more
efficient ways to do things I did "by hand" with the raw data. Can
someone enlighten me?

1. I wanted to take 24 bit data, count the colours and make an 8-bit BMP
if there are fewer than 256 colours. My brute force solution required me
to build the palette by hand from the data and rewrite the data one
pixel at a time. (a simple '.convert("P")' seems to use an arbitrary
palette or something???)

2. I wanted to pad a bitmap by adding some space to the right and
bottom. I did this by creating a new one and pasting the old one into
it.

3. I wanted to convert every occurrence of one colour to another. I
walked each pixel.

I also could not figure out how to get to a 4-bit BMP. I inferred from
the documentation that this just isn't possible with out of box PIL.

Overall: PIL really rocks.

 Paul Prescod
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Making the "outside" of an image transparent

2006-05-10 Thread Paul Moore
On 5/10/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Paul Moore wrote:
>
> > So I can get transparency set, but I still don't know a good flood
> > fill algorithm.
>
> eric raymond posted a nice implementation last year, which will go
> into 1.1.6:
>
> http://article.gmane.org/gmane.comp.python.image/1753
>
> (note that his code doesn't work on PIL Image objects; mapping this
> to corresponding PIL methods is left as an exercise etc etc)

That's the one I found, and based my code on. The problem I had was
that it floods everything until it hits a specific colour - whereas I
am looking to flood evertything of one colour, until I hit a different
colour.

It's almost the same, but something in the edge conditions went wrong, I think.

Actually, things were made worse by the fact that I was creating
images for a web page, and I hadn't realised that Internet Explorer
only seems to respect transparency in GIF files. (I was avoiding GIF,
as PIL doesn't compress them, for copyright reasons, as I understand
it). I'll go back and look again and see if I can get that algorithm
working.

Thanks,
Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Making the "outside" of an image transparent

2006-05-05 Thread Paul Moore
On 5/5/06, Paul Moore <[EMAIL PROTECTED]> wrote:
> I searched for a flood fill algorithm that would do what I wanted, and
> couldn't find anything that I could use. I did find one algorithm,
> which I tried to modify to do what I wanted, but I've clearly
> misunderstood something vital, as the resulting image looked identical
> to the original :-(

I managed to get the transparency side of things working - the big
problem was that I didn't realize GIF transparency worked differently
from other image formats, so I was doing the wrong thing there.

So I can get transparency set, but I still don't know a good flood
fill algorithm.

Thanks,
Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Making the "outside" of an image transparent

2006-05-05 Thread Paul Moore
I have a rectangular image, which is a logo on a white background. I
would like to modify the image to make the white background
transparent (in effect, giving an irregularly shaped image). I've
searched the archives, and found some details on how to make parts of
an image transparent, but they aren't quite what I need. The problem I
have is that parts of the interior of the image are also white, and
those parts I don't want to make transparent.

I searched for a flood fill algorithm that would do what I wanted, and
couldn't find anything that I could use. I did find one algorithm,
which I tried to modify to do what I wanted, but I've clearly
misunderstood something vital, as the resulting image looked identical
to the original :-(

Can anyone help me? I attach my code in case it's of use, but to be
honest, I'm not sure it's even close...

Thanks,
Paul.

import Image

def crop_background(image, colour = None):
w, h = image.size
print w*h
mask = Image.new("L", image.size)
if colour is None:
colour = image.getpixel((0, 0))
pt = 0, 0
background = set()
seen = set()
candidates = set((pt,))
while candidates:
pt = candidates.pop()
seen.add(pt)
if image.getpixel(pt) == colour:
background.add(pt)
i, j = pt
for new_i, new_j in (i+1, j), (i, j+1), (i-1, j), (i, j-1):
if 0 <= new_i < w and 0 <= new_j < h and (new_i, new_j) not in seen:
candidates.add((new_i, new_j))
pix = mask.load()
for i in range(w):
for j in range(h):
if (i, j) in background:
pix[i, j] = 0
else:
pix[i, j] = 1
image.putalpha(mask)
print len(background)
return image
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Python 2.5 binaries?

2006-04-17 Thread Paul Moore
On 4/13/06, Paul Moore <[EMAIL PROTECTED]> wrote:
> Does anyone have a binary installer for PIL with Python 2.5 on
> Windows? I can try building it myself, but traditionally, I've had a
> lot of trouble assembling all of the necessary imaging libraries, so I
> thought I'd save myself some time if some kind sould had already done
> this.

I got this built. It's not particularly hard, it's just a matter of
getting all the dependencies.

I've had an offer of hosting the file, so if anyone else wants it,
it'll be made available in due course.

Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Python 2.5 binaries?

2006-04-13 Thread Paul Moore
Does anyone have a binary installer for PIL with Python 2.5 on
Windows? I can try building it myself, but traditionally, I've had a
lot of trouble assembling all of the necessary imaging libraries, so I
thought I'd save myself some time if some kind sould had already done
this.

(Follow-up question - if no-one else has a binary, and I do build one,
would anyone like to host it to save others the trouble?)

Thanks,
Paul
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Pyvox release 0.72 now available

2006-03-17 Thread Paul Hughett

Travis,

> Thanks for releasing all of your work and for the generous license.

My pleasure.


> Do you know if and/or when your library will be interoperable with 
> NumPy?  

It's on my list of good things to do, along with 500 other items.
It's been moving towards the top, since I'd like to be able to use
Matplotlib with Pyvox.


> The new array interface makes this quite easy.

I really like the idea of having a common underlying protocol for all
multi-dimensional arrays; I'm still looking at the details of this
particular proposal.


> Perhaps the PIL could also learn to export and import the array 
> interface to finally get copy-less data-transfer with NumPy arrays.

Also a good idea.  PIL supports many more image file formats that Pyvox
ever will, so interoperability would be nice.


> On a related note.  It would be nice if we could figure out better
> ways to work together on the basic object layers for image and
> volume processing (in my mind that's what NumPy array's are most
> useful for).

Sounds good in theory, but I'm a bit unsure on the practical details.
A good starting place would seem to be a common N-D array protocol.  Do
you have any other specific suggestions?


Paul Hughett

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Pyvox release 0.72 now available

2006-03-07 Thread Paul Hughett


The source distribution kit for Pyvox version 0.72 is now available
from

   http://www.med.upenn.edu/bbl/downloads/pyvox/


Pyvox is a Python extension module for processing volume images,
particularly medical images; it also includes some examples and simple
applications.

Features added in release 0.72 include: The interface for constructing
convolution kernels has been completely redesigned and now supports
the dynamic modification of kernels.  Internal types now have min and
max attributes which contain the minimum and maximum possible finite
positive values representable in that type.

Pyvox is currently available as an alpha release under an open-source
license and is written in ANSI C and designed to be easily portable to
any Unix or Posix-compatible platform.  Some programs also require the
X Window System.


Paul Hughett


Paul Hughett, Ph.D.Research Associate
Brain Behavior Laboratory  
10th floor Gates Building
Hospital of the University (215) 662-6095 (voice)
of Pennsylvania(215) 662-7903 (fax)
3400 Spruce Street  
Philadelphia PA 19104  [EMAIL PROTECTED]

A rose by any other name confuses the issue.
  -Patrick E. Raume



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Announcing another Python imaging package?

2006-03-07 Thread Paul Hughett

I have been developing an open-source Python extension module for
volume image processing, particularly medical imaging.  Would it be
appropriate for me to announce new releases of that package on this
list?


Paul Hughett


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] apparent typo in pilfont doc

2006-01-03 Thread Paul Rubin
http://www.pythonware.com/library/pil/handbook/pilfont.htm

I think "pdf" is supposed to say "pcf".  If not, an explanation is
needed.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] vector graphics Q

2005-10-16 Thread Paul Moore
On 10/16/05, Dmitry (Dima) Strakovsky <[EMAIL PROTECTED]> wrote:
> I haven't done any testing of bitmap to SVG myself, so this is not a
> voice of experience :)
> hope this helps:
>
> http://www.scale-a-vector.de/svg-test4-e.htm
> http://autotrace.sourceforge.net/

Thanks for the linke - I'll have a look...

Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] vector graphics Q

2005-10-16 Thread Paul Moore
On 10/16/05, Dmitry (Dima) Strakovsky <[EMAIL PROTECTED]> wrote:
> Fredrick does your lib work with SVG?

I believe that PIL is for bitmap images only, and as such, SVG isn't
supported. If you look in the appendix "Image File Formats" of the PIL
handbook (http://www.pythonware.com/library/pil/handbook/index.htm)
you'll see that SVG isn't documented as being supported.

> Is there a library out there that is particularly nice (has
> resize,rotate,copy,paste type functions)for working with SVGs?

I also have some interest in vector graphics processing. (Although
it's fairly casual so far).

One specific thing I would like to be able to do is to take a bitmap
format of a line image (a scanned copy of a line drawing, to be
specific) and convert it to vector format. I realise that this isn't a
trivial task (edge detection, and so on) but are there any tools or
libraries that will do this? I haven't found any support in PIL for
this, but maybe I've missed something...

Thanks,
Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Copying EXIF data from one file or PIL image to another?

2005-06-05 Thread Paul Moore
On 6/5/05, Terry Carroll <[EMAIL PROTECTED]> wrote:
> Can anyone tell me if it's fairly easy to copy a JPEG file's EXIF data to
> another file.  Even better would be if this is doable in PIL.
> 
> My basic problem:
> 
> I've written a small program that reads a JPEG image in PIL, and creates a
> copy that is slightly modified (it overlays the image with a datestamp
> taken from the EXIF data), and saves it as a new file.  It all works
> swimmingly well, except that the ne file has no EXIF data.  I'd like to
> copy the original image's EXIF data to the new image.

You can *read* EXIF information via the _getexif() method of the
image. Use the KEYS dictionary in the ExifTags module to map numeric
keys to friendly names. For example,

>>> d = dict((ExifTags.TAGS[k], v) for k, v in im._getexif().items())
>>> d['DateTimeOriginal']
'2002:08:07 17:07:59'

Unfortunately, I don't know of a way to *write* EXIF information with PIL.

Hope this helps (a bit)
Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Rendering Japanese fonts

2005-04-20 Thread Paul Moore
On 4/20/05, Lars Yencken <[EMAIL PROTECTED]> wrote:
> I'm trying to render a Japanese font to an image, but I'm having some 
> problems.
[...]
> desiredText = unicode('nothing 日本語 appears', 'utf8').encode('euc_jp')

I don't know if you are literally including Japanese characters in
your source code, as you appear to be doing here, but unless you have
an encoding declaration in your module, this won't work - by default,
Python source code only handles ASCII characters.

Try using Unicode escapes for the Japanese characters, or reading the
characters from a file using an appropriate codec stream reader. That
might help. (If it doesn't, I'm afraid I can't help you :-))

Paul.
___
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig


Re: [Image-SIG] Compiling PIL for 2.4

2004-12-13 Thread Paul Moore
On Mon, 13 Dec 2004 08:39:45 +, Voidspace <[EMAIL PROTECTED]> wrote:
> I've just upgraded to Python 2.4. I've installed the free microsoft
> optimising compiler and hacked distutils to use it - following the
> instructions from http://www.vrplumber.com/programming/mstoolkit/ . It
> works great and I've built a windows installer for PyCrypto 2.0.
> 
> I'm attempting to compile PIL for python 2.4. The build instructions for
> windows say :

I posted some instructions to this list a couple of days ago for
building PIL with mingw. You may like to try that option (as far as I
can tell, it's not as messy as using the MS free compilers).
Alternatively, Fredrik has now published a build of PIL 1.1.5b1 for
Python 2.4, if that's of use.

Regards,
Paul.
___
Image-SIG maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/image-sig


[Image-SIG] Building PIL for Windows (Python 2.4)

2004-12-09 Thread Paul Moore
I have successfully built PIL 1.1.5b1 for Python 2.4, using the free
Mingw implementation of gcc. Here are instructions, for anyone who is
interested. (Please note, there is one place I needed to modify the
PIL sources - I'm not sure if what I did was the best way, but maybe
Fredrik could review and apply something suitable in the core
sources...)

I have mingw 3.3.3 installed - you need a recent enough version to
support building binaries which link to msvcr71. You need to have
followed the instructions in the Python documentation ("Installing
Python Modules" section 6.2.2) on building libpython24.a.

You also need the libraries freetype, tiff, jpeg, zlib and libgw32c
from the GnuWin32 project (gnuwin32.sourceforge.net). Get the
"developer files" distributions, and unzip them into a suitable
location (I used "..\Libs" relative to my PIL build directory - the
instructions below will be based on this).

>From ..\Libs\lib, delete all of the .lib and .dll.a files - these link
to DLL versions of the libraries, and can get picked up by accident.
We want to link statically, to reduce dependencies.

I also have ActiveTCL (aspn.activestate.com) installed, for the TCL/TK
header files and link libraries. You need to copy tcl84.lib to
libtcl84.a, and tk84.lib to libtk84.a, to match mingw naming
conventions.

OK, that's the environment set up.

Now, we need to fix a problem in the PIL sources. Edit ImPlatform.h,
and comment out the definition of INT64. (This definition clashes with
others in some of the Windows header files, and I found that removing
it was the quickest fix to get everything to build...)

Now, in setup.py, set the roots:

FREETYPE_ROOT = libinclude("../Libs")
JPEG_ROOT = libinclude("../Libs")
TIFF_ROOT = libinclude("../Libs")
ZLIB_ROOT = libinclude("../Libs")
TCL_ROOT = libinclude("C:/Apps/Tcl") # Or wherever you installed ActiveTCL

Finally, you need to add a couple of dependencies to the _imagingft
extension (again, in setup.py):

   exts.append(Extension(
"_imagingft", ["_imagingft.c"], libraries=["freetype",
"z", "gw32c"],
define_macros=defs
 ))

[The formatting is probably messed up here - it's the addition of "z"
and "gw32c" in the libraries argument that matters]

Now, you should just be able to build.

python setup.py build --compiler=mingw32 bdist_wininst

Paul.

PS I have a binary installer built. While I don't want to end up mass
mailing it to everyone, if anyone can offer space to host it, I'd be
happy to make it available. No guarantees beyond "it works for me",
unfortunately :-)
___
Image-SIG maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/image-sig