Skip to content

Instantly share code, notes, and snippets.

@jcupitt
jcupitt / ruby-vips-vs-oil.rb
Created August 9, 2012 14:34 — forked from stanislaw/ruby-vips-vs-oil.rb
Ruby-vips vs Oil
#!/usr/bin/env ruby
require 'rubygems'
gem 'ruby-vips'
gem 'oil'
require 'vips'
require 'oil'
@jcupitt
jcupitt / gist:3349972
Created August 14, 2012 14:53
make Burrough-style cutups
/* burr - simple filter to do cut ups for you
*
* No more scissors paper and glue! Turn your manual pages into disturbing,
* impressionistic accounts of drug addiction amongst homosexual hispanics in
* 1920's San Francisco. Turn your thesis into a lurid description of the
* thoughts of a man-crab roaming the brass streets of Minraud under a white
* hot sky. Free yourself of the language virus!
*
* Very simple minded - we:
*
@jcupitt
jcupitt / skin.py
Created January 31, 2013 13:05
detect skin tones in an image with libvips and python
#!/usr/bin/python
import sys
from vipsCC import *
im = VImage.VImage(sys.argv[1])
try:
# import to CIELAB with lcms
# 1 means relative colorimetry
@jcupitt
jcupitt / skin.rb
Created January 31, 2013 13:18
Find skin tones with ruby-vips.
#!/usr/bin/ruby
require 'rubygems'
require 'vips'
im = VIPS::Image.new(ARGV[0])
begin
# import to CIELAB with lcms
# if there's no profile there, we'll fall back to the thing below
@jcupitt
jcupitt / daltonize.rb
Created January 31, 2013 13:23
Simulate Deuteranope vision in ruby-vips.
#!/usr/bin/ruby
require 'rubygems'
require 'vips'
a = VIPS::Image.jpeg(ARGV[0], :sequential => true)
# import to CIELAB colour space using the ICC profile embedded in the image
lab = a.icc_import_embedded(:relative)
@jcupitt
jcupitt / vips-7.26 and ruby-vips 0.3.6 install log
Created August 29, 2013 11:04
vips-7.26 and ruby-vips install log, showing libexif functioning
john@mm-jcupitt3 ~/GIT/libvips (7.26) $ CFLAGS="-g -Wall" CXXFLAGS="-g -Wall" ./configure --prefix=/home/john/vips-7.26
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for native Win32... no
checking for binary open needed... no
@jcupitt
jcupitt / try207.c
Created January 15, 2014 09:25
try repeated save to a buffer
/* compile with
*
* gcc -g -Wall try207.c `pkg-config vips --cflags --libs`
*/
#include <stdio.h>
#include <vips/vips.h>
int
@jcupitt
jcupitt / try208.c
Created January 16, 2014 09:18
demo defining and using a new vips operator
/* compile with
*
* gcc -g -Wall try208.c `pkg-config vips --cflags --libs`
*/
#include <vips/vips.h>
/* Create a tiny VipsOperator ... photographic negative of a uchar image.
*/
@jcupitt
jcupitt / introspect.c
Last active August 29, 2015 13:55
simple vips8 introspection example
/* vips8 introspection demo
*
* compile with:
*
* gcc -g -Wall introspect.c `pkg-config vips --cflags --libs`
*
* This example needs vips 7.39 or later.
*
* try:
*
@jcupitt
jcupitt / trim.rb
Last active April 30, 2023 02:32
auto-crop in ruby-vips
#!/usr/bin/env ruby
# "trim" is nnow built in, so this is easy
require 'vips'
im = Vips::Image.new_from_file(ARGV[0])
left, top, width, height = im.find_trim
im = im.crop(left, top, width, height)