Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf-test.git/shortlog/05609efbb88bce492605d720667d7111c379115a
...commit 
http://git.netsurf-browser.org/netsurf-test.git/commit/05609efbb88bce492605d720667d7111c379115a
...tree 
http://git.netsurf-browser.org/netsurf-test.git/tree/05609efbb88bce492605d720667d7111c379115a

The branch, master has been updated
       via  05609efbb88bce492605d720667d7111c379115a (commit)
      from  e85ed06c23df3049dee8ae8f31f295b01170411e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf-test.git/commit/?id=05609efbb88bce492605d720667d7111c379115a
commit 05609efbb88bce492605d720667d7111c379115a
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    CGI: Add image.cgi
    
    Image generator CGI, supports:
    
      width=xxx
      height=xxx
      format=xxx
    
    Formats supported include: png, jpeg, bmp, ico, gif, webp
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/cgi-bin/image.cgi b/cgi-bin/image.cgi
new file mode 100755
index 0000000..b128c3a
--- /dev/null
+++ b/cgi-bin/image.cgi
@@ -0,0 +1,54 @@
+#!/usr/bin/python3
+
+import cgi
+import cgitb
+import sys
+cgitb.enable()
+
+import os
+from base64 import b64decode
+
+auth = os.getenv("HTTP_AUTHORIZATION")
+query = os.getenv("QUERY_STRING") or ""
+
+query = cgi.parse_qs(query)
+
+width = query.get("width", ["100"])[0]
+height = query.get("height", ["100"])[0]
+fmt = query.get("format", "png")[0]
+
+try:
+    width = int(width)
+except:
+    width = 100
+
+try:
+    height = int(height)
+except:
+    height = 100
+    
+width = width if width > 0 else 100
+height = height if height > 0 else 100
+
+FORMATS = {
+    "png":  { "ctype": "image/png",  "ptype": "png" },
+    "jpeg": { "ctype": "image/jpeg", "ptype": "jpeg" },
+    "bmp":  { "ctype": "image/bmp",  "ptype": "bmp" },
+    "ico":  { "ctype": "image/ico",  "ptype": "ico" },
+    "gif":  { "ctype": "image/gif",  "ptype": "gif" },
+    "webp": { "ctyle": "image/webp", "ptype": "webp" },
+}
+
+fmt = FORMATS.get(fmt)
+
+if fmt is None:
+    fmt = FORMATS["png"]
+
+from PIL import Image
+
+im = Image.new('RGB', (width, height))
+im.putdata([(255,0,0)] * (width * height))
+
+print("Content-Type: {}".format(fmt["ctype"]))
+print("")
+im.save(fp=sys.stdout.buffer, format=fmt["ptype"])


-----------------------------------------------------------------------

Summary of changes:
 cgi-bin/image.cgi |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100755 cgi-bin/image.cgi

diff --git a/cgi-bin/image.cgi b/cgi-bin/image.cgi
new file mode 100755
index 0000000..b128c3a
--- /dev/null
+++ b/cgi-bin/image.cgi
@@ -0,0 +1,54 @@
+#!/usr/bin/python3
+
+import cgi
+import cgitb
+import sys
+cgitb.enable()
+
+import os
+from base64 import b64decode
+
+auth = os.getenv("HTTP_AUTHORIZATION")
+query = os.getenv("QUERY_STRING") or ""
+
+query = cgi.parse_qs(query)
+
+width = query.get("width", ["100"])[0]
+height = query.get("height", ["100"])[0]
+fmt = query.get("format", "png")[0]
+
+try:
+    width = int(width)
+except:
+    width = 100
+
+try:
+    height = int(height)
+except:
+    height = 100
+    
+width = width if width > 0 else 100
+height = height if height > 0 else 100
+
+FORMATS = {
+    "png":  { "ctype": "image/png",  "ptype": "png" },
+    "jpeg": { "ctype": "image/jpeg", "ptype": "jpeg" },
+    "bmp":  { "ctype": "image/bmp",  "ptype": "bmp" },
+    "ico":  { "ctype": "image/ico",  "ptype": "ico" },
+    "gif":  { "ctype": "image/gif",  "ptype": "gif" },
+    "webp": { "ctyle": "image/webp", "ptype": "webp" },
+}
+
+fmt = FORMATS.get(fmt)
+
+if fmt is None:
+    fmt = FORMATS["png"]
+
+from PIL import Image
+
+im = Image.new('RGB', (width, height))
+im.putdata([(255,0,0)] * (width * height))
+
+print("Content-Type: {}".format(fmt["ctype"]))
+print("")
+im.save(fp=sys.stdout.buffer, format=fmt["ptype"])


-- 
NetSurf test cases

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to