Changeset 990 for CMESS/mediaplayer/branches
- Timestamp:
- 28.04.2010 15:11:53 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMESS/mediaplayer/branches/zmsgraphic_extedit/zmsgraphic_extedit.metaobj.xml
r986 r990 1517 1517 </item> 1518 1518 <item type="dictionary"><dictionary> 1519 <item key="custom"><![CDATA[# Example code: 1520 1521 def ZMSGraphic_extEdit_crop(): 1522 return "This is the external method ZMSGraphic_extEdit_crop" 1523 ]]></item> 1519 <item key="custom"><![CDATA[from time import localtime, strftime 1520 from PIL import Image 1521 from cStringIO import StringIO 1522 import os.path 1523 1524 def ZMSGraphic_extEdit_crop(dest_folder, source_id, coords, dest_id = None, unique_filename = False): 1525 if (dest_folder is not None): 1526 if (not source_id in dest_folder.objectIds()): 1527 raise 'ZMSGraphic_extEdit_crop: can\'t find source-image' 1528 1529 temp_source = getattr(dest_folder, source_id) 1530 temp_source = StringIO(str(temp_source.data)) 1531 1532 temp_image = Image.open(temp_source) 1533 temp_image = temp_image.convert('RGB') 1534 temp_thumb = temp_image.crop(coords) 1535 temp_image_size = temp_thumb.size 1536 1537 temp_dest = StringIO() 1538 temp_thumb.save(temp_dest, "JPEG") 1539 temp_dest.seek(0) 1540 1541 temp_path, temp_ext = os.path.splitext(source_id) 1542 temp_dest_id = (dest_id is None) and temp_path or dest_id 1543 if (unique_filename): 1544 temp_dest_id += '_%s'%strftime('%Y%m%d%H%M%S', localtime()) 1545 temp_dest_id = temp_path + '_thumb.jpg' 1546 1547 if (temp_dest_id in dest_folder.objectIds()): 1548 dest_folder.manage_delObjects(temp_dest_id) 1549 1550 dest_folder.manage_addImage(temp_dest_id, temp_dest) 1551 1552 temp_result = temp_dest_id 1553 temp_result = (temp_dest_id, temp_image_size[0], temp_image_size[1]) 1554 else: 1555 temp_result = None 1556 1557 return temp_result]]></item> 1524 1558 <item key="id"><![CDATA[ZMSGraphic_extEdit_crop]]></item> 1525 1559 <item key="mandatory" type="int">0</item> … … 1535 1569 import os.path 1536 1570 1537 def ZMSGraphic_extEdit_resize(dest_folder, source_id, max_width, max_height = None, replace_source = False):1571 def ZMSGraphic_extEdit_resize(dest_folder, source_id, max_width, max_height = None, dest_id = None, replace_source = False): 1538 1572 if (dest_folder is not None): 1539 1573 if (not source_id in dest_folder.objectIds()): … … 1556 1590 1557 1591 temp_path, temp_ext = os.path.splitext(source_id) 1558 temp_dest_id = temp_path1592 temp_dest_id = (dest_id is None) and temp_path or dest_id 1559 1593 if (not replace_source): 1560 1594 temp_dest_id += '_preview' … … 1591 1625 # @param methods list of FLIP_LEFT_RIGHT (0), FLIP_TOP_BOTTOM (1), ROTATE_90 (2), ROTATE_180 (3) or ROTATE_270 (4) 1592 1626 1593 def ZMSGraphic_extEdit_transpose(dest_folder, source_id, methods, replace_source = False, unique_filename = False):1627 def ZMSGraphic_extEdit_transpose(dest_folder, source_id, methods, replace_source = False, dest_id = None, unique_filename = False): 1594 1628 if (dest_folder is not None): 1595 1629 if (not source_id in dest_folder.objectIds()): … … 1605 1639 temp_image = temp_image.convert('RGB') 1606 1640 for one_method in methods: 1607 print (str(one_method))1608 1641 temp_image = temp_image.transpose(one_method) 1609 1642 temp_image_size = temp_image.size … … 1614 1647 1615 1648 temp_path, temp_ext = os.path.splitext(source_id) 1616 temp_dest_id = temp_path1649 temp_dest_id = (dest_id is None) and temp_path or dest_id 1617 1650 if (not replace_source): 1618 1651 temp_dest_id += '_preview' … … 1620 1653 temp_dest_id += '_%s'%strftime('%Y%m%d%H%M%S', localtime()) 1621 1654 temp_dest_id += '.jpg' 1622 1623 print (temp_dest_id)1624 1655 1625 1656 if (replace_source): … … 2097 2128 <item key="name"><![CDATA[com.zms.zmsgraphic_extedit]]></item> 2098 2129 <item key="package"/> 2099 <item key="revision"><![CDATA[0.1. 0]]></item>2130 <item key="revision"><![CDATA[0.1.1]]></item> 2100 2131 <item key="type"><![CDATA[ZMSPackage]]></item> 2101 2132 </dictionary>
Note: See TracChangeset
for help on using the changeset viewer.
