If you want the downsampling algorithm used by the Gimp and (I think)
Photoshop, try:
def stretch(im, size, filter=Image.NEAREST):
im.load()
im = im._new(im.im.stretch(size, filter))
return im
In 2005 I found it to be a few times quicker than ANTIALIAS resizing,
and the results were
Peter Yen colorp...@gmail.com wrote:
Thanks for your quick response. The background is unknown at the time of
processing. Actually I don't need a very accurate methodology to remove all
background, removing partially is good enough.
I once wrote a (GPL'd) C module that fairly reliably
Karsten Hiddemann schrieb:
Fredrik has written something about the performance on pixel access with
some timings here: http://effbot.org/zone/pil-pixel-access.htm
As that page also mentions, PIL images have the point method for doing
this kind of thing.
see
TAN TH wrote:
import Image
im = Image.open(D:/test.gif)
print im.format, im.size, im.mode
GIF (409, 460) P
The P is telling you that the image is in palette mode (as all gifs
are), but here you are assuming it is RGB mode:
r, g, b = im.split()
What you really want is
r, g, b =
I wrote:
2 ** (31-20) ** 0.5
9.9633077752473778
A pixel difference of 10 across the 1 megapixel image will wrap the sum
and crash.
But now I've read it and it looks like it should have been
(2 ** (31-20)) ** 0.5
45.254833995939045
So, not so bad, but nonetheless a problem.
douglas
hi Andy
Here's the resized gif with the original code I pasted. You'll see a
bunch of 'dots' throughout the image:
http://www.andymccurdy.com/resized_1.gif
PIL uses the so-called web palette by default. Your image uses
#fdfdfd for white, but the web palette uses #ff. So it dithers to
Andy McCurdy [EMAIL PROTECTED] wrote:
I interpreted your response as a setting to change to make this
specific image resize better. I'm using PIL to resize images that
users upload to my website. Since I don't have control over the
media, I need generic settings that will be good for all
Carl Karsten wrote:
I am trying to convert a pdf (data in string, not disk file) to a png. This
will be run in a django view on a server (PyCon's even) so it would be good
if
it didn't hit the disk as much. Shouldn't I be able to use .tostring if I
can
use .save?
use cStringIO.
Daniel Felix Ferber wrote:
When taking a photo with high ISO on a digital camera, there will be
many pixels that have a random color that is completely different color
from the expected one. But the photo still has a good sharpness
ImageMagic uses a stategy that is similar to the median
A cropped image does not return a pixel access object when load()ed.
This seems to be a simple oversight.
im = Image.new('L',(50,50))
im.load()
PixelAccess object at 0xb7d900f0
im2 = im.crop((0, 0, 20, 20))
im2.load()
None
There is an easy workaround:
im2.im.pixel_access()
Lad wrote:
But I would like to write the text to the lower left bottom, starting 30
pixels from left and 30
from the bottom.
So I use
textpos=(im.size[0]-30,im.size[1]-30)
but it does not work. There si no text written.
Can you please tell me why?
30 pixels from the left, with the top
Bill Janssen wrote:
I keep getting different values for s.median than I get for h.index(v).
Shouldn't they be the same value? Am I missing something?
Isn't it *mode* that you are calculating, not median? The median would
be calculated by adding up the histogram values until you have
John Barratt wrote:
http://www.langarson.com.au/blog/?p=14
This is an observation, not a recommendation, but you could *almost* do
all of this in pure PIL, without explicit loops. You could find the
slope like so:
dxfilter = ImageFilter((3,3), [1, 0, -1,
hi John,
Method Time (s)Times slower than fastest
+-+ +---+ ++
ctypes,c,GD raw 0.00082 1.0
ctypes,c,GD 0.00177 2.2
PIL - 'load'0.03226 39.4
ctypes, GD 0.14428 176.4
PIL, numpy *
Cochran, Travis wrote:
I'm trying to use the PIL to create a grayscale ramp, dark to light. I
am able to generate an image but it is solid black. Am I using
frombuffer wrong? Here is my code.
from PIL import Image
#Creates the list of codes from 0 to 255
data = range(256)
#Creates an
, expand = 1)
im2.show()
Douglas Bagnall
___
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig
Alec Bennett wrote:
Hmm, still getting a black box. The code as it stands now in case
anything jumps out at you:
# open the pic and give it an alpha channel so it's transparent
im1 = Image.open(pic1.jpg)
im1.convert('RGBA')
That should be
im1 = Image.open(pic1.jpg)
im1 =
Alec Bennett wrote:
collage.paste(im2, (30, 30) )
From http://effbot.org/imagingbook/image.htm#Image.paste :
im.paste(image, box, mask)
Same as above, but updates only the regions indicated by the
mask. You can use either 1, L or RGBA images (in the latter
case, the alpha band is used
hi Peter,
Thanks for the reply folks. Here is the code I have produced so far...
#! /usr/bin/python
import sys
import string
Don't use the string module, use the string type methods:
http://python.org/doc/2.3.5/lib/string-methods.html
Read the next page too, about string formatting.
Lorenzo Bolognini wrote:
from PIL import Image, ImageDraw, ImageFont
im = Image.new(RGB, (150,70), #fff)
draw = ImageDraw.Draw(im, RGB)
font = ImageFont.truetype(trebuc.ttf, 30)
draw.text((20,20), Hello World!, fill=#ff, font=font)
im.save(C:\\pippo.png, PNG)
[...]
So the question is:
I've added stretched versions to
http://halo.gen.nz/pil/examples.html
With javascript, clicking on the top image should cycle through the
unscaled, area averaged, anti-aliased, and nearest-neighbour-stetched
images.
+ I'm beginning to wonder if there's not an off-by-something error
lurking
21 matches
Mail list logo