[Bf-docboard-svn] bf-manual: [7105] trunk/blender_docs/tools_maintenance/update_screenshots.py: Update Screenshots: Refactor crop to function
Aaron Carlisle
carlisle.b3d at gmail.com
Fri Sep 25 01:45:41 CEST 2020
Revision: 7105
https://developer.blender.org/rBM7105
Author: Blendify
Date: 2020-09-25 01:45:41 +0200 (Fri, 25 Sep 2020)
Log Message:
-----------
Update Screenshots: Refactor crop to function
Modified Paths:
--------------
trunk/blender_docs/tools_maintenance/update_screenshots.py
Modified: trunk/blender_docs/tools_maintenance/update_screenshots.py
===================================================================
--- trunk/blender_docs/tools_maintenance/update_screenshots.py 2020-09-24 23:18:17 UTC (rev 7104)
+++ trunk/blender_docs/tools_maintenance/update_screenshots.py 2020-09-24 23:45:41 UTC (rev 7105)
@@ -158,7 +158,28 @@
)
yield
+
# ----------------------------------------------------------------------
+# Screenshot Helpers
+
+def crop(filepath, size_dst):
+ import imbuf
+
+ ibuf = imbuf.load(filepath)
+ size_src = ibuf.size
+ min = (
+ (size_src[0] // 2) - (size_dst[0] // 2) - 1,
+ (size_src[1] // 2) - (size_dst[1] // 2) - 1,
+ )
+ max = (
+ min[0] + size_dst[0],
+ min[1] + size_dst[1],
+ )
+ ibuf.crop(min=min, max=max)
+ imbuf.write(ibuf, filepath)
+
+
+# ----------------------------------------------------------------------
# Screenshot Startup
def screenshot_startup(window):
@@ -214,21 +235,7 @@
yield from window_tap_key(window=window, type='ESC')
- # Crop.
- import imbuf
- ibuf = imbuf.load(filepath)
- size_dst = 520, 487
- size_src = ibuf.size
- min = (
- (size_src[0] // 2) - (size_dst[0] // 2) - 1,
- (size_src[1] // 2) - (size_dst[1] // 2) - 1,
- )
- max = (
- min[0] + size_dst[0],
- min[1] + size_dst[1],
- )
- ibuf.crop(min=min, max=max)
- imbuf.write(ibuf, filepath)
+ crop(filepath, [520, 487])
# ----------------------------------------------------------------------
More information about the Bf-docboard-svn
mailing list