Skip to content

Instantly share code, notes, and snippets.

@jcupitt
jcupitt / structure-data.sh
Created November 27, 2020 13:57
final stage of struct pipeline
#!/bin/bash
run() {
cmd="$*"
$cmd
if [ $? != 0 ]; then
echo =====================
echo $cmd
echo failed
exit 1
@jcupitt
jcupitt / bench-read.py
Created August 21, 2020 00:35
benchmark pyvips vs cv2 for image read
#!/usr/bin/python3
# setup with:
#
# mkdir sample
# cd sample
# for i in {1..300}; do cp ~/pics/k2.png $i.png; done
#
# on this modest 2015 laptop running Ubuntu 20.04, I see:
#
@jcupitt
jcupitt / litecor.py
Created August 4, 2020 14:33
light correction example with pyvips
#!/usr/bin/python3
import sys
import os
import pyvips
if len(sys.argv) < 3:
print(f"usage: {sys.argv[0]} grey-card-image image1 image2 ...")
print(f" light-correct a set of images with a grey card")
print(f" corrected images writtem to lc_image1, lc_image2, etc.")
@jcupitt
jcupitt / Vips-8.0.gir
Created July 7, 2020 09:44
sample libvips GIR
This file has been truncated, but you can view the full file.
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GObject" version="2.0"/>
<c:include name="vips/vips.h"/>
@jcupitt
jcupitt / custom.c
Created March 22, 2020 17:12
custom libvips source and target in C
/* Compile with:
*
* gcc -g -Wall custom.c `pkg-config vips --cflags --libs`
*
* Run with:
*
* ./a.out ~/pics/k2.jpg x.jpg
*
*/
@jcupitt
jcupitt / watermark_fax2.c
Created March 3, 2020 09:52
render dithered text with libvips
/* watermark a fax image with vips8 C
*
* compile with
gcc -g -Wall watermark_fax.c `pkg-config vips --cflags --libs`
*/
#include <vips/vips.h>
@jcupitt
jcupitt / watermark_fax.c
Created March 2, 2020 11:40
watermark a fax image with libvips
/* watermark a fax image with vips8 C
*
* compile with
gcc -g -Wall watermark_fax.c `pkg-config vips --cflags --libs`
*/
#include <vips/vips.h>
@jcupitt
jcupitt / dominant.php
Last active November 5, 2019 20:49
make a solid image of the dominant colour
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
use Jcupitt\Vips;
$im = Vips\Image::newFromFile($argv[1], ['access' => 'sequential']);
# 3D histogram ... make 10 x 10 x 10 bins, so 1000 possible colours
$n_bins = 10;
@jcupitt
jcupitt / gooble.html
Last active October 28, 2019 15:43
attach a handler
<!DOCTYPE html>
<html>
<head>
<title>HELLO GOOBLERAMPLING</title>
</head>
<body>
<a href="viewerPage.html" target="_blank" id="myPicture">
<img src="thePic.png">
</a>
@jcupitt
jcupitt / introspect.c
Created October 18, 2019 14:19
libvips introspection demo
/* vips8 introspection demo
*
* compile with:
*
* gcc -g -Wall introspect.c `pkg-config vips --cflags --libs`
*
* This example needs vips 7.39 or later.
*
* try:
*