Skip to content

Instantly share code, notes, and snippets.

@yoya
yoya / imaging_resize.go
Last active August 28, 2018 04:15
disintegration/imaging resize test
package main
import (
"flag"
"github.com/disintegration/imaging"
"image/png"
"os"
)
func main() {
@yoya
yoya / pil_imageops_equalize_gamma.py
Last active August 16, 2018 18:37
pil_imageops_equalize_gamma.py
from PIL import Image, ImageOps
import sys
import numpy as np
def gamma_correction(im, gamma):
arr = np.asarray(im)
arr = 255.0 * (arr / 255.0)**(gamma)
return Image.fromarray(np.uint8(arr))
im = Image.open(sys.argv[1])
@yoya
yoya / pil_imageops_equalize.py
Last active August 16, 2018 18:35
pil_imageops_equalize.py
from PIL import Image, ImageOps
import sys
im = Image.open(sys.argv[1])
im = im.convert("YCbCr")
yy, cb, cr = im.split()
yy = ImageOps.equalize(yy);
im = Image.merge("YCbCr", (yy, cb, cr))
@yoya
yoya / imageops_method.py
Created August 10, 2018 15:47
ImageOps any method call
from PIL import Image, ImageOps
import sys
if len(sys.argv) < 4:
print ("Usage: python imageopt_test.py <grayscale|equalize|...> [<value>] <infile> <outfile>\n")
print (dir(ImageOps))
exit (0);
method = sys.argv[1]
if len(sys.argv) == 4:
@yoya
yoya / http_server.py
Last active July 6, 2018 15:35
python http server
#! /usr/local/bin/python3
# https://docs.python.jp/3/library/http.server.html
# https://blog.sarabande.jp/post/81479479934
from http.server import HTTPServer, SimpleHTTPRequestHandler
[host, port] = ["0.0.0.0", 4848]
class MyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
@yoya
yoya / PIL_grayscale.py
Last active June 21, 2019 14:54
PIL Grayscale improve
# (c) [email protected] 2019/06/20-
# ref) https://pillow.readthedocs.io/en/stable/reference/Image.html
import sys
from PIL import Image
_rgb2xyz_rec709 = (
0.412453, 0.357580, 0.180423, 0,
0.212671, 0.715160, 0.072169, 0, # RGB mixing weight
0.019334, 0.119193, 0.950227, 0 )
@yoya
yoya / pentile_rgbw2.php
Created June 2, 2018 15:20
pentile rgbw 2 SVG
<?php
/*
* (c) 2017/08/21- [email protected]
* $ composer require yoya/php-svg
*/
require_once("vendor/autoload.php");
use SVG\SVGImage;
use SVG\Nodes\Structures\SVGStyle;
use SVG\Nodes\Structures\SVGDefs;
@yoya
yoya / pentile_rgb.php
Last active June 2, 2018 08:26
pentile rgb SVG (check)
<?php
/*
* (c) 2017/08/21- [email protected]
* $ composer require yoya/php-svg
*/
require_once("vendor/autoload.php");
use SVG\SVGImage;
use SVG\Nodes\Structures\SVGStyle;
use SVG\Nodes\Structures\SVGDefs;
@yoya
yoya / pentile_rgb_w.php
Created June 2, 2018 06:56
pentile rgb w SVG
<?php
/*
* (c) 2017/08/21- [email protected]
* $ composer require yoya/php-svg
*/
require_once("vendor/autoload.php");
use SVG\SVGImage;
use SVG\Nodes\Structures\SVGStyle;
use SVG\Nodes\Structures\SVGDefs;
@yoya
yoya / pentile_rgbw.php
Created June 2, 2018 06:48
pentile rgbw SVG
<?php
/*
* (c) 2017/08/21- [email protected]
* $ composer require yoya/php-svg
*/
require_once("vendor/autoload.php");
use SVG\SVGImage;
use SVG\Nodes\Structures\SVGStyle;
use SVG\Nodes\Structures\SVGDefs;