|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Problem when resizing large JPEG to thumbnailHi, I'm using sorl-thumbnail in Django to automatically resize my images. sorl-thumbnail use PIL to do is image manipulations. Unfortunately the result thumbnails are far from pretty. You can see some tests here: http://www.teknozen.net/resize_pil.html Here's the code I (and sorl) use to create the thumbnails: im = Image.open('source.jpg') if im.mode not in ("L", "RGB", "RGBA"): __im = im.convert("RGB") im = im.crop((568, 783, 3164, 3379)) im = im.resize((70, 70), resample=Image.ANTIALIAS) im.save('pil.jpg', "JPEG", quality=95) Pretty straightforward. I did some tests with ImageMagick to compare the result. The difference is huge. The ImageMagick thumbnail looks great. In contrast he PIL thumbnail look blocky and blurry at the same time and the colors are all fade out. I don't think the jpeg compression is the problem, I set it to 95. I did a test with resample=Image.BICUBIC and the result is really bad. But I don't think that BICUBIC was really applied because I got the exactly same result when I use resample=Image.NEAREST. Also, at the beginning, my source file was a TIFF in CMYK. The color of the generated thumbnail was completely off. That's why I convert it to RGB JPEG in Photoshop. So after experimenting, I see 3 problems: 1. Resize with ANTIALIAS from a large JPEG to a small thumbnail give poor image quality. 2. BICUBIC, when set, is not applied. Instead NEAREST is use. 3. Converting from TIFF CMYK to RGB shift the colors dramatically. Is all theses points are normal behavior ? Etienne _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailOn Mon, Aug 31, 2009 at 7:44 PM, Etienne Desautels <tiit@...> wrote:
> > Hi, > > I'm using sorl-thumbnail in Django to automatically resize my images. > sorl-thumbnail use PIL to do is image manipulations. > > Unfortunately the result thumbnails are far from pretty. You can see some > tests here: > http://www.teknozen.net/resize_pil.html > > Here's the code I (and sorl) use to create the thumbnails: > > im = Image.open('source.jpg') > > if im.mode not in ("L", "RGB", "RGBA"): > __im = im.convert("RGB") > > im = im.crop((568, 783, 3164, 3379)) > > im = im.resize((70, 70), resample=Image.ANTIALIAS) > > im.save('pil.jpg', "JPEG", quality=95) > > Pretty straightforward. I did some tests with ImageMagick to compare the > result. The difference is huge. The ImageMagick thumbnail looks great. In > contrast he PIL thumbnail look blocky and blurry at the same time and the > colors are all fade out. I don't think the jpeg compression is the problem, > I set it to 95. > > I did a test with resample=Image.BICUBIC and the result is really bad. But I > don't think that BICUBIC was really applied because I got the exactly same > result when I use resample=Image.NEAREST. > > Also, at the beginning, my source file was a TIFF in CMYK. The color of the > generated thumbnail was completely off. That's why I convert it to RGB JPEG > in Photoshop. > > > So after experimenting, I see 3 problems: > 1. Resize with ANTIALIAS from a large JPEG to a small thumbnail give poor > image quality. > 2. BICUBIC, when set, is not applied. Instead NEAREST is use. > 3. Converting from TIFF CMYK to RGB shift the colors dramatically. > > Is all theses points are normal behavior ? > > Etienne > _______________________________________________ > Image-SIG maillist - Image-SIG@... > http://mail.python.org/mailman/listinfo/image-sig > I am not familiar with sorl-thumbnail, so I can't say as to the exact workings, but from your example it looks like you are just using PIL. The thumbnail looks ok to me, the only thing that perhaps might be different between the ImageMagic and the PIL is a color profile. PIL does not automatically retain extra information attached with an image (too hard to tell if it is still valid in the general case) so perhaps if your monitor is calibrated nicely you would notice a difference. As to the CMYK issue, this has been discussed before, and is still and open issue, I believe, although there might be a workaround--search the mailing lists. Edward _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailOn Tue, Sep 1, 2009 at 4:44 AM, Etienne Desautels <tiit@...> wrote:
> So after experimenting, I see 3 problems: > 1. Resize with ANTIALIAS from a large JPEG to a small thumbnail give poor > image quality. This should work fine in 1.1.6; no time to look at your tests right now, but I'll do that asap. > 2. BICUBIC, when set, is not applied. Instead NEAREST is use. The problem you're seeing is that PIL's BICUBIC filter has a fixed size, and thus doesn't work well for large downsamplings (there's a discussion about this in the documentation, iirc). The ANTIALIAS filter does not have that shortcoming. > 3. Converting from TIFF CMYK to RGB shift the colors dramatically. This is a bug in 1.1.6 and earlier (well, strictly speaking, it's a old bug in Photoshop, but I guess we're not really in a position to make them change their implementation ;-). It's fixed in 1.1.7. There's also a drop-in replacement JPEG plugin by Kevin Cazabon that fixes this for earlier versions (in a somewhat roundabout way, due to a bug in the core library that has also been fixed in 1.1.7); see: http://mail.python.org/pipermail/image-sig/2006-April/003871.html </F> _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailOn 09-09-28, at 07:22, Fredrik Lundh wrote: > On Tue, Sep 1, 2009 at 4:44 AM, Etienne Desautels > <tiit@...> wrote: > >> So after experimenting, I see 3 problems: >> 1. Resize with ANTIALIAS from a large JPEG to a small thumbnail >> give poor >> image quality. > > This should work fine in 1.1.6; no time to look at your tests right > now, but I'll do that asap. Since I wrote this, I resize (downsample) a lot more images with PIL and in general the result is excellent. The problem appear only with the kind of images I choose to do my initial tests, image of concentric circles or alike. Now I'm pretty sure that the poor result I saw is a special edge case of the antialias algorithm used in PIL. I can't see any other explanation. >> 2. BICUBIC, when set, is not applied. Instead NEAREST is use. > > The problem you're seeing is that PIL's BICUBIC filter has a fixed > size, and thus doesn't work well for large downsamplings (there's a > discussion about this in the documentation, iirc). The ANTIALIAS > filter does not have that shortcoming. Ho, yes I see. >> 3. Converting from TIFF CMYK to RGB shift the colors dramatically. > > This is a bug in 1.1.6 and earlier (well, strictly speaking, it's a > old bug in Photoshop, but I guess we're not really in a position to > make them change their implementation ;-). It's fixed in 1.1.7. > There's also a drop-in replacement JPEG plugin by Kevin Cazabon that > fixes this for earlier versions (in a somewhat roundabout way, due to > a bug in the core library that has also been fixed in 1.1.7); see: > > http://mail.python.org/pipermail/image-sig/2006-April/003871.html I saw some threads about this bug but I was with the impression that applied only to the JPEG plugin, not to the CMYK support in general ? Etienne > </F> > _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailOn Mon, Sep 28, 2009 at 5:01 PM, Etienne Desautels <tiit@...> wrote:
>>> 3. Converting from TIFF CMYK to RGB shift the colors dramatically. >> >> This is a bug in 1.1.6 and earlier (well, strictly speaking, it's a >> old bug in Photoshop, but I guess we're not really in a position to >> make them change their implementation ;-). It's fixed in 1.1.7. >> There's also a drop-in replacement JPEG plugin by Kevin Cazabon that >> fixes this for earlier versions (in a somewhat roundabout way, due to >> a bug in the core library that has also been fixed in 1.1.7); see: >> >> http://mail.python.org/pipermail/image-sig/2006-April/003871.html > > I saw some threads about this bug but I was with the impression that applied > only to the JPEG plugin, not to the CMYK support in general ? Oh, sorry - misread your question. Yes, bad colour shifts are quite common if you use the default approximation (which doesn't take the colour profile into account). For better results, you want PIL 1.1.7 with littlecms and the ImagingCMS module (see the list archives for pointers to the development repo). </F> _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailSorry for posting in to parts. On 09-09-28, at 07:22, Fredrik Lundh wrote: > On Tue, Sep 1, 2009 at 4:44 AM, Etienne Desautels > <tiit@...> wrote: > >> 3. Converting from TIFF CMYK to RGB shift the colors dramatically. > > This is a bug in 1.1.6 and earlier (well, strictly speaking, it's a > old bug in Photoshop, but I guess we're not really in a position to > make them change their implementation ;-). It's fixed in 1.1.7. > There's also a drop-in replacement JPEG plugin by Kevin Cazabon that > fixes this for earlier versions (in a somewhat roundabout way, due to > a bug in the core library that has also been fixed in 1.1.7); see: I saw that there's a lot of things fixed and added in 1.1.7. For me the inclusion of pyCMS is great (always looking for ways to improve image quality). If I have some time I will test 1.1.7 from tip. Do you know when you will release the final version ? It looks like your not really far from releasing. Etienne _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
|
|
Re: Problem when resizing large JPEG to thumbnailOn Mon, Sep 28, 2009 at 5:11 PM, Etienne Desautels <tiit@...> wrote:
> Do you know when you will release the final version ? It looks like your not > really far from releasing. The release should have been cut ages ago, but last-second bug reports pushed it into my vacation. And when you don't make a proper release in time, people come up with more things that really should have been in the release, so you'll add a few more issues to the to-do-before-release list, and ... but it shouldn't be very far away now. </F> _______________________________________________ Image-SIG maillist - Image-SIG@... http://mail.python.org/mailman/listinfo/image-sig |
| Free embeddable forum powered by Nabble | Forum Help |