def rotate90Image(self, original_id, obj):
  """
  Rotate an image to 90 degrees clockwise
  (270 counter-clockwise) around its center.
  """

  from PIL import Image
  from StringIO import StringIO
  import os.path

  # create a rotated image file
  original_image=getattr(self, original_id)
  original_file=StringIO(str(original_image.data))
  original_items=original_image.propertyItems()
  image=Image.open(original_file)
  image=image.convert('RGB')
  image.seek(0)
  image90=image.rotate(270)
  rotated_file=StringIO()
  image90.save(rotated_file, "JPEG") 
  rotated_file.seek(0)

  # record the name, value, type of each original property
  p_name,p_value,p_type=[],[],[]
  n=len(original_items)
  for i in range(n):
    p_name.append(original_items[i][0])
    p_value.append(original_items[i][1])
    p_type.append(original_image.getPropertyType(p_name[i]))

  original_date=obj[original_id].bobobase_modification_time()
    
  # delete original image
  obj.manage_delObjects([original_id])
  
  # create the Zope image object
  obj.manage_addProduct['OFSP'].manage_addImage(original_id, rotated_file, '')
  rotated_image=getattr(self, original_id)
  
  # add and change properties
  for i in range(n):
    if not (p_name[i] in ['title','content_type','height','width']):
      rotated_image.manage_addProperty(p_name[i],p_value[i],p_type[i])
    elif p_name[i]=='title':
      rotated_image.manage_changeProperties(title=p_value[i])
  if not rotated_image.hasProperty('faketime'):
    rotated_image.manage_addProperty('faketime',original_date,'date')

