community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1839225 - in /comdev/project-logos/tools: compile.py poweredby.py
Date Sun, 26 Aug 2018 15:27:05 GMT
Author: humbedooh
Date: Sun Aug 26 15:27:04 2018
New Revision: 1839225

URL: http://svn.apache.org/viewvc?rev=1839225&view=rev
Log:
add higher res default, enable forcing re-rendering, add Powered-By generator. fix paths

Added:
    comdev/project-logos/tools/poweredby.py
Modified:
    comdev/project-logos/tools/compile.py

Modified: comdev/project-logos/tools/compile.py
URL: http://svn.apache.org/viewvc/comdev/project-logos/tools/compile.py?rev=1839225&r1=1839224&r2=1839225&view=diff
==============================================================================
--- comdev/project-logos/tools/compile.py (original)
+++ comdev/project-logos/tools/compile.py Sun Aug 26 15:27:04 2018
@@ -11,12 +11,15 @@ import time
 
 # Standard in/out dirs
 img_dir = '/svn/project-logos/originals'
-out_dir = '/var/www/html/logos/res'
+out_dir = '/var/www/logos/site/res'
+
+force = False
 
 if len(sys.argv) > 2:
     img_dir = sys.argv[1]
     out_dir = sys.argv[2]
-
+if len(sys.argv) > 3 and sys.argv[3] == 'force':
+  force = True
 
 # svn up before processing
 subprocess.check_output(('/usr/bin/svn', 'up', img_dir))
@@ -109,7 +112,7 @@ for file in files:
   fpath = '%s/%s' % (img_dir, file)
   st = os.stat(fpath)
   skipit = False
-  if st.st_mtime < (time.time() - 4200) and os.path.exists('%s/%s/default.png' % (out_dir,
project)):
+  if st.st_mtime < (time.time() - 4200) and os.path.exists('%s/%s/default.png' % (out_dir,
project)) and not force:
     print("Skipping %s" % fpath)
     skipit = True
   # EPS should be converted to PDF first, or inkscape borks :/
@@ -130,6 +133,7 @@ for file in files:
           if xfile == project or xfile == '%s-1' % project:
               if not skipit:
                 subprocess.check_output(('inkscape', '-z', '%s/%s' % (img_dir, file), '-e',
'%s/%s/default.png' % (out_dir, project), '-w', '720'))
+                subprocess.check_output(('inkscape', '-z', '%s/%s' % (img_dir, file), '-e',
'%s/%s/default_hr.png' % (out_dir, project), '-w', '1200'))
               projects[project]['has_default'] = True
       except:
           pass

Added: comdev/project-logos/tools/poweredby.py
URL: http://svn.apache.org/viewvc/comdev/project-logos/tools/poweredby.py?rev=1839225&view=auto
==============================================================================
--- comdev/project-logos/tools/poweredby.py (added)
+++ comdev/project-logos/tools/poweredby.py Sun Aug 26 15:27:04 2018
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import subprocess
+import json
+import requests
+import re
+from PIL import Image
+import time
+import math
+
+res_dir = '/var/www/logos/site/res'
+pb_image = '/var/www/logos/site/images/poweredby.png'
+pb_dir = '/var/www/logos/site/poweredby'
+
+projects = [x for x in os.listdir(res_dir) if os.path.isdir(os.path.join(res_dir, x))]
+
+for project in sorted(projects):
+    if os.path.exists('%s/%s/default_hr.png' % (res_dir, project)):
+        back = Image.open(pb_image)
+        front = Image.open('%s/%s/default_hr.png' % (res_dir, project))
+        
+        w = front.width
+        h = front.height
+        to_edge = math.sqrt(((w/2)*(w/2)) + ((h/2)*(h/2)))
+        while to_edge > 475:
+            w *= 0.995
+            h *= 0.995
+            to_edge = math.sqrt(((w/2)*(w/2)) + ((h/2)*(h/2)))
+        w = int(w)
+        h = int(h)
+        print("Generating 'Powered By' for %s (%u x %u)..." % (project, w, h))
+        size = (w, h)
+        front.thumbnail(size, Image.ANTIALIAS)
+        
+        centerx = int((back.width/2) - (w/2))
+        centery = int((back.height/2) - (h/2))
+        back.paste(front, (centerx, centery), front)
+        
+        back.save('%s/%s.png' % (pb_dir, project), 'PNG')
+        
\ No newline at end of file



Mime
View raw message