2017-04-30 10:39:12 +01:00
|
|
|
# expkg-zone58:image.thumbnailator
|
2017-07-28 12:04:50 +01:00
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
An XQuery interface to the image thumbnail generator library
|
2021-02-16 23:05:20 +00:00
|
|
|
[thumbnailator](https://github.com/coobird/thumbnailator) for BaseX 9.4.5+.
|
2013-06-10 22:35:14 +01:00
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
Features size, scale, caption, rotate, flip, colorize, watermark. More details at [doc](doc/readme.md)
|
2013-06-10 22:35:14 +01:00
|
|
|
|
2017-11-24 23:48:45 +00:00
|
|
|
## Versions
|
2021-02-16 23:05:20 +00:00
|
|
|
* thumbnailator 8 requires Basex 9.4.5+
|
|
|
|
* uses thumbnailator 4.13
|
2017-04-21 14:48:37 +01:00
|
|
|
## Usage
|
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
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`
|
|
|
|
|
2017-04-21 14:48:37 +01:00
|
|
|
### Simple
|
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
Create a thumbnail of given size
|
2017-04-21 14:48:37 +01:00
|
|
|
```xquery
|
|
|
|
import module namespace t="expkg-zone58:image.thumbnailator";
|
|
|
|
|
|
|
|
fetch:binary("http://images.metmuseum.org/CRDImages/ep/original/DT46.jpg")
|
2017-04-30 10:39:12 +01:00
|
|
|
=>t:size(80)
|
|
|
|
```
|
|
|
|
or scale to a fraction of the original
|
|
|
|
|
|
|
|
```xquery
|
|
|
|
import module namespace t="expkg-zone58:image.thumbnailator";
|
2017-04-21 14:48:37 +01:00
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
fetch:binary("file:///Z:/recordings/radio/Book%20of%20the%20Week/image.png")
|
|
|
|
=>t:scale(0.25)
|
2017-04-21 14:48:37 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Tasks
|
|
|
|
This function takes an XML description of the operations to apply to generate the thumbnail.
|
|
|
|
|
2017-04-21 15:06:49 +01:00
|
|
|
```xquery
|
|
|
|
import module namespace t="expkg-zone58:image.thumbnailator";
|
|
|
|
declare variable $watermark:="C:\Users\andy\git\ex-thumbnailator\src\test\resources\icon.jpg";
|
|
|
|
|
|
|
|
let $task:=
|
2017-04-21 14:48:37 +01:00
|
|
|
<thumbnail>
|
2017-04-21 15:06:49 +01:00
|
|
|
<size width="100" height="100"/>
|
2017-04-21 14:48:37 +01:00
|
|
|
<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>
|
2017-04-21 15:06:49 +01:00
|
|
|
|
|
|
|
return fetch:binary("http://images.metmuseum.org/CRDImages/ep/original/DT46.jpg")
|
|
|
|
=>t:task($task)
|
2017-04-21 14:48:37 +01:00
|
|
|
```
|
2017-04-30 10:39:12 +01:00
|
|
|
The schema for this XML is available at [task.xsd](./src/main/content/task.xsd)
|
2017-04-21 14:48:37 +01:00
|
|
|
|
|
|
|
## Installation
|
2013-06-10 22:35:14 +01:00
|
|
|
The library is packaged in the [EXpath](http://expath.org/spec/pkg) xar format with
|
2017-04-30 11:04:04 +01:00
|
|
|
the thumbnailator jar included. See [releases](../../releases) for installation instructions.
|
2017-04-21 14:48:37 +01:00
|
|
|
|
2013-06-10 22:35:14 +01:00
|
|
|
# Tests
|
2016-04-16 22:21:17 +01:00
|
|
|
`test.xqm` script uses the BaseX [Unit module](http://docs.basex.org/wiki/Unit_Module)
|
|
|
|
|
2017-04-21 14:48:37 +01:00
|
|
|
## License
|
|
|
|
|
2017-11-24 23:48:45 +00:00
|
|
|
* ex-thumbnailator Copyright (c) 2013-2017, Andy Bunce. (Apache 2 License).
|
2017-04-21 14:48:37 +01:00
|
|
|
* thumbnailator Copyright (c) Chris Kroells (MIT License).
|
|
|
|
|
2016-04-16 22:21:17 +01:00
|
|
|
|
2017-04-30 10:39:12 +01:00
|
|
|
|