[Image-SIG] Memory Error
Fredrik Lundh
fredrik at pythonware.com
Mon Feb 4 18:00:47 CET 2008
Dennis Kepler wrote:
> I seem to be having a memory problem, except all I'm doing is applying a
> contrast enhancement to a .tiff or .jpg. I get this error: *return
> im1._new(core.blend(im1.im, im2.im, alpha)) MemoryError*
> **
> The JPEG is about 45mb.
> The TIFF is about 600mb.
>
> My code looks like this:
> import sys, os
> import glob, time
> import Image, ImageDraw, ImageFont
> import ImageEnhance
>
> os.chdir('D:/Ortho/jpg_outputs/cem/test/')
>
> #set image list by a glob search
> img_list = glob.glob('*.jpg')
>
> # Start the loop of the images to be resized
> for img in img_list:
> name = img
> im = Image.open(img)
> enh = ImageEnhance.Contrast(im)
> enh.enhance(1.3).show("30% more contrast")
>
> #Save full resolution jpeg
> try:
> im.save('D:/ortho/jpg_outputs/cem/test/output/' + name[0:8] +
> ".jpg")
> except IOError:
> print "cannot export", name
>
> Any ideas?
use the windows task manager to check how quickly memory grows; do you
run out of memory after one images, five, ten? how much memory does
each loop need?
also, note that ImageEnhance isn't a very memory efficient way to
process large images; the constructor makes *two* copies of the source
image, and the enhance method generates a third one. try using the
"point" method instead.
</F>
More information about the Image-SIG
mailing list