Go to file
Andy Bunce e3778bb3ba
continuous-integration/drone/push Build was killed Details
add .drone
2021-05-22 22:18:26 +01:00
.settings task interface and java helper 2017-04-21 14:48:37 +01:00
dist [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
doc v5 2017-04-30 10:39:12 +01:00
lib [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
src [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
tools basex v9 stream->lazy 2017-11-24 23:48:45 +00:00
.classpath [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
.drone.yml add .drone 2021-05-22 22:18:26 +01:00
.gitignore task interface and java helper 2017-04-21 14:48:37 +01:00
.project task interface and java helper 2017-04-21 14:48:37 +01:00
LICENSE update to thumbnailator 0.4.8 2016-04-16 22:21:17 +01:00
catalog.xml task interface and java helper 2017-04-21 14:48:37 +01:00
makejar.jardesc [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
package.xml [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
readme.md update readme 2021-05-22 22:11:08 +01:00

readme.md

expkg-zone58:image.thumbnailator

An XQuery interface to the image thumbnail generator library thumbnailator for BaseX 9.4.5+.

Features size, scale, caption, rotate, flip, colorize, watermark. More details at doc

Versions

  • ex-thumbnailator 8 requires Basex 9.4.5+
  • uses thumbnailator 4.13

Usage

Images are input and output as xs:base64Binary items. Inputs typically come from fetch:binary which allows for file and http sources. Outputs may be saved with file:write-binary or db:store

Simple

Create a thumbnail of given size

import module namespace t="expkg-zone58:image.thumbnailator";

fetch:binary("http://images.metmuseum.org/CRDImages/ep/original/DT46.jpg")
=>t:size(80)

or scale to a fraction of the original

import module namespace t="expkg-zone58:image.thumbnailator";

fetch:binary("file:///Z:/recordings/radio/Book%20of%20the%20Week/image.png")
=>t:scale(0.25)

Tasks

This function takes an XML description of the operations to apply to generate the thumbnail.

import module namespace t="expkg-zone58:image.thumbnailator";
declare variable $watermark:="C:\Users\andy\git\ex-thumbnailator\src\test\resources\icon.jpg";

let $task:=
<thumbnail>
    <size width="100" height="100"/>
    <filters>             
        <colorize color="green" alpha=".5"/>      
        <caption position="CENTER">Some Text here</caption>
        <rotate angle="15"/>
        <canvas height="500" width="500" position="TOP_LEFT" color="black"/> 
        <watermark src="{$watermark}" alpha=".5"  position="TOP_LEFT"/>  
    </filters>         
</thumbnail>

return fetch:binary("http://images.metmuseum.org/CRDImages/ep/original/DT46.jpg")
=>t:task($task)

The schema for this XML is available at task.xsd

Installation

The library is packaged in the EXpath xar format with the thumbnailator jar included. See releases for installation instructions.

Tests

test.xqm script uses the BaseX Unit module

License

  • ex-thumbnailator Copyright (c) 2013-2017, Andy Bunce. (Apache 2 License).
  • thumbnailator Copyright (c) Chris Kroells (MIT License).