pil rotate 90 bug ?

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

pil rotate 90 bug ?

Jeremy Craven
I have a program that has been working fine rotating images by arbitrary
angles.

I just found that if I specify 90 degrees exactly then the image goes
crazy: only appears in left hand half of image and every other line is
black and image is stretched vertically.

Any ideas if this is a bug or I am perhaps doing something in a
non-recommended way.

I attach a cut down version of the code which shows the problem. It
reads "test_in.tif". It rotates it 90.0 and writes "test.tif". It
rotates it 89.99 and writes "test1.tif". The second output file looks
fine. The first is wonky.

I'm using version 1.1.7

Thanks for listening

Jeremy

--
*********************************************************************************

Dr C. Jeremy Craven
Department of Molecular Biology and Biotechnology
University of Sheffield,
Firth Court, Western Bank
S10 2TN Sheffield UK

e-mail: [hidden email]
http://www.shef.ac.uk/uni/projects/nmr/CJC/CJC.html

Phone:                       x24323
 From outside Sheffield:      0114 222 4323
 From outside UK:             +44 114 2224323
Fax:                         0114 272 2800

*********************************************************************************




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

test.tif (1M) Download Attachment
test1.tif (1M) Download Attachment
test_rotate.py (250 bytes) Download Attachment
test_in.tif (1M) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: pil rotate 90 bug ?

Charlie Clark-6
Am 28.07.2011, 11:43 Uhr, schrieb Jeremy Craven  
<[hidden email]>:

> I have a program that has been working fine rotating images by arbitrary  
> angles.
> I just found that if I specify 90 degrees exactly then the image goes  
> crazy: only appears in left hand half of image and every other line is  
> black and image is stretched vertically.
> Any ideas if this is a bug or I am perhaps doing something in a  
> non-recommended way.
> I attach a cut down version of the code which shows the problem. It  
> reads "test_in.tif". It rotates it 90.0 and writes "test.tif". It  
> rotates it 89.99 and writes "test1.tif". The second output file looks  
> fine. The first is wonky.

Dear Jeremy,

first off - it's extremely uncourteous to post such a large e-mail to a  
mailing list. Much better to put the attachments on a temporary site  
somewhere. Secondly, all the images are black to me so I can't see any  
difference between them.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: pil rotate 90 bug ?

Guilherme Polo
In reply to this post by Jeremy Craven
2011/7/28 Jeremy Craven <[hidden email]>:

> I have a program that has been working fine rotating images by arbitrary
> angles.
>
> I just found that if I specify 90 degrees exactly then the image goes crazy:
> only appears in left hand half of image and every other line is black and
> image is stretched vertically.
>
> Any ideas if this is a bug or I am perhaps doing something in a
> non-recommended way.
>

It is a bug, it doesn't rotate the image by 90 degrees.

Looking through PIL code, I would think the problem is that you have
these "special images" with mode as "I;16B", which PIL marks as
IMAGING_TYPE_SPECIAL. The code paths used for such special things
probably are under tested.

> I attach a cut down version of the code which shows the problem. It reads
> "test_in.tif". It rotates it 90.0 and writes "test.tif". It rotates it 89.99
> and writes "test1.tif". The second output file looks fine. The first is
> wonky.
>
> I'm using version 1.1.7
>
> Thanks for listening
>
> Jeremy
>
> --
> *********************************************************************************
>
> Dr C. Jeremy Craven
> Department of Molecular Biology and Biotechnology
> University of Sheffield,
> Firth Court, Western Bank
> S10 2TN Sheffield UK



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

Re: pil rotate 90 bug ?

Edward Cannon-2
A possible workaround is to convert the images to some more standard format ie im.convert("rgb"). If you need to rotate by multiples of 90 the transform method works and is faster.



On Aug 4, 2011, at 1:24 PM, Guilherme Polo <[hidden email]> wrote:

> 2011/7/28 Jeremy Craven <[hidden email]>:
>> I have a program that has been working fine rotating images by arbitrary
>> angles.
>>
>> I just found that if I specify 90 degrees exactly then the image goes crazy:
>> only appears in left hand half of image and every other line is black and
>> image is stretched vertically.
>>
>> Any ideas if this is a bug or I am perhaps doing something in a
>> non-recommended way.
>>
>
> It is a bug, it doesn't rotate the image by 90 degrees.
>
> Looking through PIL code, I would think the problem is that you have
> these "special images" with mode as "I;16B", which PIL marks as
> IMAGING_TYPE_SPECIAL. The code paths used for such special things
> probably are under tested.
>
>> I attach a cut down version of the code which shows the problem. It reads
>> "test_in.tif". It rotates it 90.0 and writes "test.tif". It rotates it 89.99
>> and writes "test1.tif". The second output file looks fine. The first is
>> wonky.
>>
>> I'm using version 1.1.7
>>
>> Thanks for listening
>>
>> Jeremy
>>
>> --
>> *********************************************************************************
>>
>> Dr C. Jeremy Craven
>> Department of Molecular Biology and Biotechnology
>> University of Sheffield,
>> Firth Court, Western Bank
>> S10 2TN Sheffield UK
>
>
>
> --
> -- Guilherme H. Polo Goncalves
> _______________________________________________
> 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: pil rotate 90 bug ?

Chris Mitchell-2

You could load the image into numpy, rotate the array, then read it back out to pil.

On Aug 4, 2011 4:39 PM, "Edward Cannon" <[hidden email]> wrote:
> A possible workaround is to convert the images to some more standard format ie im.convert("rgb"). If you need to rotate by multiples of 90 the transform method works and is faster.
>
>
>
> On Aug 4, 2011, at 1:24 PM, Guilherme Polo <[hidden email]> wrote:
>
>> 2011/7/28 Jeremy Craven <[hidden email]>:
>>> I have a program that has been working fine rotating images by arbitrary
>>> angles.
>>>
>>> I just found that if I specify 90 degrees exactly then the image goes crazy:
>>> only appears in left hand half of image and every other line is black and
>>> image is stretched vertically.
>>>
>>> Any ideas if this is a bug or I am perhaps doing something in a
>>> non-recommended way.
>>>
>>
>> It is a bug, it doesn't rotate the image by 90 degrees.
>>
>> Looking through PIL code, I would think the problem is that you have
>> these "special images" with mode as "I;16B", which PIL marks as
>> IMAGING_TYPE_SPECIAL. The code paths used for such special things
>> probably are under tested.
>>
>>> I attach a cut down version of the code which shows the problem. It reads
>>> "test_in.tif". It rotates it 90.0 and writes "test.tif". It rotates it 89.99
>>> and writes "test1.tif". The second output file looks fine. The first is
>>> wonky.
>>>
>>> I'm using version 1.1.7
>>>
>>> Thanks for listening
>>>
>>> Jeremy
>>>
>>> --
>>> *********************************************************************************
>>>
>>> Dr C. Jeremy Craven
>>> Department of Molecular Biology and Biotechnology
>>> University of Sheffield,
>>> Firth Court, Western Bank
>>> S10 2TN Sheffield UK
>>
>>
>>
>> --
>> -- Guilherme H. Polo Goncalves
>> _______________________________________________
>> 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

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

Re: pil rotate 90 bug ?

Donn-11
In reply to this post by Jeremy Craven
Aw man, a 2.3mb email -- on my scant monthly b/w. Please don't do this
on a list. Pretty please.

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