Skip to content

Instantly share code, notes, and snippets.

  1. Get all of these files into the target folder
  2. Run the following commands:
chmod +x *.sh
./nginx-start.sh
@jindili
jindili / dominant-lab.py
Created October 21, 2017 09:06 — forked from jcupitt/dominant-lab.py
find dominant colour in an 8-bit RGB Image with libvips python
#!/usr/bin/python
import sys
from gi.repository import Vips
N_BINS = 10
BIN_SIZE = 256 / N_BINS
im = Vips.Image.new_from_file(sys.argv[1], access = Vips.Access.SEQUENTIAL)
@jindili
jindili / watermark.py
Created October 21, 2017 09:07 — forked from jcupitt/watermark.py
watermarking with vips8 python
#!/usr/bin/python
import sys
from gi.repository import Vips
im = Vips.Image.new_from_file(sys.argv[1], access = Vips.Access.SEQUENTIAL)
text = Vips.Image.text(sys.argv[3], width = 500, dpi = 300)
text = (text * 0.3).cast("uchar")
text = text.embed(100, 100, text.width + 200, text.width + 200)
@jindili
jindili / trim.py
Created October 21, 2017 09:07 — forked from jcupitt/trim.py
auto-trim with vips8 python
#!/usr/bin/env python
import sys
from gi.repository import Vips
# An equivalent of ImageMagick's -trim in pyvip8 ... automatically remove
# "boring" image edges.
# We use .project to sum the rows and columns of a 0/255 mask image, the first
@jindili
jindili / premultiply.py
Created October 21, 2017 09:07 — forked from jcupitt/premultiply.py
more premultiplication experiments
#!/usr/bin/python
import sys
from gi.repository import Vips
image = Vips.Image.new_from_file(sys.argv[1])
# get the alpha
alpha = image[3]
@jindili
jindili / slice.py
Created October 21, 2017 09:08 — forked from jcupitt/slice.py
slice a large array with pyvips8
#!/usr/bin/env python
import sys
import gi
gi.require_version('Vips', '8.0')
from gi.repository import Vips
# load the array from the file
#!/usr/bin/python
import sys
import json
from gi.repository import Vips
def cut_image(im, json_data, debug = False):
# Coordinates are stored in json format as list of x/y-coords
# [[x0,y0],[x1,y1],...,[xn,yn]]
@jindili
jindili / smartcrop.py
Created October 21, 2017 09:08 — forked from jcupitt/smartcrop.py
smartcrop with Vips and Python
#!/usr/bin/python
# smartcrop with libvips, based very roughly on
# https://github.com/jwagner/smartcrop.js
import sys
import gi
gi.require_version('Vips', '8.0')
from gi.repository import Vips
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of the Z9 Slide Imaging & Analysis Platform.
# Copyright (C) 2015 Jonas Ogaard
#
# Z9 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of the Z9 Slide Imaging & Analysis Platform.
# Copyright (C) 2015 Jonas Ogaard
#
# Z9 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#