Skip to content

Instantly share code, notes, and snippets.

@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:
*
@jcupitt
jcupitt / test.svg
Created September 11, 2019 16:01
test svg image
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcupitt
jcupitt / sample output
Created September 3, 2019 11:52
make random strings
$ python3 tile_server.py
Wooo!!! I made this: RGPRRPPBRPBRYGBBGYPYYRBYRYYYPYPGPBRPBRYRYGYYBRYRYPRRBPGGRGGPRYYBRBRPRGGBYGRRYGGRPGBRPGPGBYGRGYBRGPPB
@jcupitt
jcupitt / final_overlap.py
Created September 5, 2018 07:54
join two images and get info on the join transform
#!/usr/bin/python
import sys
import pyvips
# you can set the size of the window as well, but 10x10 pixels (the default) is
# probably fine
left = pyvips.Image.new_from_file(sys.argv[1])
right = pyvips.Image.new_from_file(sys.argv[2])
@jcupitt
jcupitt / pyvips_test.py
Created August 16, 2018 14:41
how to handle BytesIO in pyvips
import asyncio
from functools import partial
from io import BytesIO
import aiohttp
import pyvips
async def get_image():
async with aiohttp.ClientSession() as session:
async with session.get("https://user-images.githubusercontent.com/29148882/43419292-d2ae9d68-9440-11e8-80f5-dcdaaae59e2e.png") as req:
image_bytes = BytesIO(await req.read())
john@kiwi:~$ rm -rf .local
john@kiwi:~$ pip3 install pyvips --user --verbose
Collecting pyvips
1 location(s) to search for versions of pyvips:
* https://pypi.python.org/simple/pyvips/
Getting page https://pypi.python.org/simple/pyvips/
Looking up "https://pypi.python.org/simple/pyvips/" in the cache
Returning cached "301 Moved Permanently" response (ignoring date and etag information)
Looking up "https://pypi.org/simple/pyvips/" in the cache
Current age based on date: 6736
<?xml version="1.0"?>
<root xmlns="http://www.vips.ecs.soton.ac.uk/nip/8.7.0">
<Workspace window_x="50" window_y="78" window_width="1536" window_height="841" view="WORKSPACE_MODE_REGULAR" scale="1" offset="0" locked="false" lpane_position="255" lpane_open="false" rpane_position="954" rpane_open="true" local_defs="// private definitions for this tab&#10;" name="tab2" caption="Default empty tab" filename="$HOME/try/annotate.ws" major="8" minor="6">
<Column x="0" y="0" open="true" selected="true" sform="false" next="4" name="A">
<Subcolumn vislevel="3">
<Row popup="false" name="A1">
<Rhs vislevel="3" flags="7">
<iImage image_left="0" image_top="0" image_mag="0" show_status="false" show_paintbox="false" show_convert="false" show_rulers="false" scale="0" offset="0" falsecolour="false" type="true"/>
<Subcolumn vislevel="1"/>
<iText formula="Magick_NewImageMenu_item.Magick_builtin_item.action"/>
@jcupitt
jcupitt / annotate.ws
Created June 8, 2018 17:00
annotate an image with nip2
<?xml version="1.0"?>
<root xmlns="http://www.vips.ecs.soton.ac.uk/nip/8.6.1">
<Workspace window_x="807" window_y="128" window_width="1078" window_height="1123" view="WORKSPACE_MODE_REGULAR" scale="1" offset="0" locked="false" lpane_position="100" lpane_open="false" rpane_position="400" rpane_open="false" local_defs="// private definitions for this tab&#10;" name="tab1" caption="Default empty tab" filename="$HOME/pics/annotate.ws" major="8" minor="6">
<Column x="0" y="0" open="true" selected="true" sform="false" next="6" name="A">
<Subcolumn vislevel="3">
<Row popup="false" name="A2">
<Rhs vislevel="1" flags="1">
<iImage image_left="0" image_top="0" image_mag="0" show_status="false" show_paintbox="false" show_convert="false" show_rulers="false" scale="0" offset="0" falsecolour="false" type="true"/>
<Subcolumn vislevel="0"/>
<iText formula="Image_file &quot;$HOME/pics/IMG_4481.jpg&quot;"/>
@jcupitt
jcupitt / config.h
Created May 30, 2018 10:08
libvips config.h for win64
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* define to open non-text files in binary mode */
#define BINARY_OPEN 1
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* The prefix for our gettext translation domains. */