Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
e3778bb3ba | |||
7138b46f65 | |||
78e8f1b28a | |||
|
460987bfec | ||
45f06ca4e2 | |||
a6a38601fd | |||
9294164247 | |||
15560b26a3 | |||
bb089e9a60 | |||
1e74f304f3 |
27 changed files with 399 additions and 318 deletions
.classpath.drone.yml
dist
lib
makejar.jardescpackage.xmlreadme.mdsrc
java/org/expkgzone58/image
main
basex.xml
content
thumbhelper-5.0.11.jarthumbhelper-8.0.0.jarthumbnailator-0.4.13.jarthumbnailator-0.4.8.jarthumbnailator.xqm
expath-pkg.xmltest
tools
24
.classpath
24
.classpath
|
@ -1,12 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src/java"/>
|
<classpathentry kind="src" path="src/java"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="lib" path="C:/Program Files (x86)/BaseX/BaseX.jar" sourcepath="/basex-core/src"/>
|
<classpathentry kind="lib" path="lib/BaseX945.jar"/>
|
||||||
<classpathentry kind="lib" path="src/main/content/thumbnailator-0.4.8.jar"/>
|
<classpathentry kind="lib" path="src/main/content/thumbnailator-0.4.13.jar"/>
|
||||||
<classpathentry kind="output" path="build/classes"/>
|
<classpathentry kind="output" path="build/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
10
.drone.yml
Normal file
10
.drone.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: test
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- go build
|
||||||
|
- go test
|
379
dist/doc/thumbnailator.xqm.xml
vendored
379
dist/doc/thumbnailator.xqm.xml
vendored
|
@ -1,187 +1,194 @@
|
||||||
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0">
|
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0">
|
||||||
<xqdoc:control>
|
<xqdoc:control>
|
||||||
<xqdoc:date>2017-04-29T22:28:45.705+01:00</xqdoc:date>
|
<xqdoc:date>2021-02-16T23:01:20.669Z</xqdoc:date>
|
||||||
<xqdoc:version>1.1</xqdoc:version>
|
<xqdoc:version>1.1</xqdoc:version>
|
||||||
</xqdoc:control>
|
</xqdoc:control>
|
||||||
<xqdoc:module type="library">
|
<xqdoc:module type="library">
|
||||||
<xqdoc:uri>expkg-zone58:image.thumbnailator</xqdoc:uri>
|
<xqdoc:uri>expkg-zone58:image.thumbnailator</xqdoc:uri>
|
||||||
<xqdoc:name>thumbnailator.xqm</xqdoc:name>
|
<xqdoc:name>thumbnailator.xqm</xqdoc:name>
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>Generate image thumbnails using the thumbnailator library.</xqdoc:description>
|
<xqdoc:description>Generate image thumbnails using the thumbnailator library.</xqdoc:description>
|
||||||
<xqdoc:see>https://github.com/coobird/thumbnailator</xqdoc:see>
|
<xqdoc:see>https://github.com/coobird/thumbnailator</xqdoc:see>
|
||||||
<xqdoc:author>andy bunce</xqdoc:author>
|
<xqdoc:author>andy bunce</xqdoc:author>
|
||||||
<xqdoc:version>0.5</xqdoc:version>
|
<xqdoc:version>0.6</xqdoc:version>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
</xqdoc:module>
|
</xqdoc:module>
|
||||||
<xqdoc:namespaces>
|
<xqdoc:imports>
|
||||||
<xqdoc:namespace prefix="thumbnails" uri="expkg-zone58:image.thumbnailator"/>
|
<xqdoc:import type="library">
|
||||||
<xqdoc:namespace prefix="Thumbs" uri="org.expkgzone58.image.Thumbs"/>
|
<xqdoc:uri>org.expkgzone58.image.Thumbs</xqdoc:uri>
|
||||||
</xqdoc:namespaces>
|
</xqdoc:import>
|
||||||
<xqdoc:imports>
|
</xqdoc:imports>
|
||||||
<xqdoc:import type="library">
|
<xqdoc:namespaces>
|
||||||
<xqdoc:uri>org.expkgzone58.image.Thumbs</xqdoc:uri>
|
<xqdoc:namespace prefix="thumbnails" uri="expkg-zone58:image.thumbnailator"/>
|
||||||
</xqdoc:import>
|
<xqdoc:namespace prefix="Thumbs" uri="org.expkgzone58.image.Thumbs"/>
|
||||||
</xqdoc:imports>
|
</xqdoc:namespaces>
|
||||||
<xqdoc:variables/>
|
<xqdoc:variables/>
|
||||||
<xqdoc:functions>
|
<xqdoc:functions>
|
||||||
<xqdoc:function arity="2">
|
<xqdoc:function arity="2">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>generate scaled version of source image with maximum dimension of size</xqdoc:description>
|
<xqdoc:description>generate scaled version of source image with maximum dimension of size</xqdoc:description>
|
||||||
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
||||||
<xqdoc:return>base64Binary for thumbnail</xqdoc:return>
|
<xqdoc:return>base64Binary for thumbnail</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:size</xqdoc:name>
|
<xqdoc:name>thumbnails:size</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:size($source as xs:base64Binary, $size as xs:integer) as xs:base64Binary</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:size($source as xs:base64Binary , $size as xs:integer) as xs:base64Binary</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>source</xqdoc:name>
|
<xqdoc:name>source</xqdoc:name>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>size</xqdoc:name>
|
<xqdoc:name>size</xqdoc:name>
|
||||||
<xqdoc:type>xs:integer</xqdoc:type>
|
<xqdoc:type>xs:integer</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="3">
|
<xqdoc:function arity="3">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>generate scaled version of source image with maximum dimension of size</xqdoc:description>
|
<xqdoc:description>generate scaled version of source image with maximum dimension of size</xqdoc:description>
|
||||||
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
||||||
<xqdoc:return>base64Binary for thumbnail</xqdoc:return>
|
<xqdoc:return>base64Binary for thumbnail</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:size</xqdoc:name>
|
<xqdoc:name>thumbnails:size</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:size($source as xs:base64Binary, $width as xs:integer, $height as xs:integer) as xs:base64Binary</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:size($source as xs:base64Binary , $width as xs:integer , $height as xs:integer) as xs:base64Binary</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>source</xqdoc:name>
|
<xqdoc:name>source</xqdoc:name>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>width</xqdoc:name>
|
<xqdoc:name>width</xqdoc:name>
|
||||||
<xqdoc:type>xs:integer</xqdoc:type>
|
<xqdoc:type>xs:integer</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>height</xqdoc:name>
|
<xqdoc:name>height</xqdoc:name>
|
||||||
<xqdoc:type>xs:integer</xqdoc:type>
|
<xqdoc:type>xs:integer</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="2">
|
<xqdoc:function arity="2">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>generate scaled version of source image at given factors 0-1</xqdoc:description>
|
<xqdoc:description>generate scaled version of source image at given factors 0-1</xqdoc:description>
|
||||||
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
||||||
<xqdoc:return>the thumbnail</xqdoc:return>
|
<xqdoc:return>the thumbnail</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:scale</xqdoc:name>
|
<xqdoc:name>thumbnails:scale</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:scale($source as xs:base64Binary, $scale as xs:double) as xs:base64Binary</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:scale($source as xs:base64Binary , $scale as xs:double) as xs:base64Binary</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>source</xqdoc:name>
|
<xqdoc:name>source</xqdoc:name>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>scale</xqdoc:name>
|
<xqdoc:name>scale</xqdoc:name>
|
||||||
<xqdoc:type>xs:double</xqdoc:type>
|
<xqdoc:type>xs:double</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="3">
|
<xqdoc:function arity="3">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>generate scaled version of source image at given factors 0-1</xqdoc:description>
|
<xqdoc:description>generate scaled version of source image at given factors 0-1</xqdoc:description>
|
||||||
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
||||||
<xqdoc:return>the thumbnail</xqdoc:return>
|
<xqdoc:return>the thumbnail</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:scale</xqdoc:name>
|
<xqdoc:name>thumbnails:scale</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:scale($source as xs:base64Binary, $xscale as xs:double, $yscale as xs:double) as xs:base64Binary</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:scale($source as xs:base64Binary , $xscale as xs:double , $yscale as xs:double) as xs:base64Binary</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>source</xqdoc:name>
|
<xqdoc:name>source</xqdoc:name>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>xscale</xqdoc:name>
|
<xqdoc:name>xscale</xqdoc:name>
|
||||||
<xqdoc:type>xs:double</xqdoc:type>
|
<xqdoc:type>xs:double</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>yscale</xqdoc:name>
|
<xqdoc:name>yscale</xqdoc:name>
|
||||||
<xqdoc:type>xs:double</xqdoc:type>
|
<xqdoc:type>xs:double</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="2">
|
<xqdoc:function arity="2">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>generate thumbnail using parameters specified via XML</xqdoc:description>
|
<xqdoc:description>generate thumbnail using parameters specified via XML</xqdoc:description>
|
||||||
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
<xqdoc:param>$source base64Binary (streamed?) e.g from `fetch:binary`</xqdoc:param>
|
||||||
<xqdoc:param>$task XML parameters <task><size width="100" ..</xqdoc:param>
|
<xqdoc:param>$task XML parameters <task><size width="100" ..</xqdoc:param>
|
||||||
<xqdoc:return>the thumbnail</xqdoc:return>
|
<xqdoc:return>the thumbnail</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:task</xqdoc:name>
|
<xqdoc:name>thumbnails:task</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:task($source as xs:base64Binary, $task as element(thumbnail)) as xs:base64Binary</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:task($source as xs:base64Binary , $task as element(thumbnail)) as xs:base64Binary</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>source</xqdoc:name>
|
<xqdoc:name>source</xqdoc:name>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>task</xqdoc:name>
|
<xqdoc:name>task</xqdoc:name>
|
||||||
<xqdoc:type>element(thumbnail)</xqdoc:type>
|
<xqdoc:type>element(thumbnail)</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
<xqdoc:type>xs:base64Binary</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="1">
|
<xqdoc:function arity="1">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
|
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
|
||||||
<xqdoc:param>$src XML parameters <thumbnail><size width="100" ..</xqdoc:param>
|
<xqdoc:param>$src XML parameters <thumbnail><size width="100" ..</xqdoc:param>
|
||||||
<xqdoc:return>empty-sequence or error</xqdoc:return>
|
<xqdoc:return>empty-sequence or error</xqdoc:return>
|
||||||
<xqdoc:error>BXVA0001: the validation fails.</xqdoc:error>
|
<xqdoc:error>BXVA0001: the validation fails.</xqdoc:error>
|
||||||
<xqdoc:error>BXVA0002: the validation process cannot be started.</xqdoc:error>
|
<xqdoc:error>BXVA0002: the validation process cannot be started.</xqdoc:error>
|
||||||
<xqdoc:error>BXVA0003: no XML Schema validator is available.</xqdoc:error>
|
<xqdoc:error>BXVA0003: no XML Schema validator is available.</xqdoc:error>
|
||||||
<xqdoc:error>BXVA0004: no validator is found for the specified version.</xqdoc:error>
|
<xqdoc:error>BXVA0004: no validator is found for the specified version.</xqdoc:error>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:validate</xqdoc:name>
|
<xqdoc:name>thumbnails:validate</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:validate($src as item()*) as empty-sequence()</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:validate($src as item()*) as empty-sequence()</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>src</xqdoc:name>
|
<xqdoc:name>src</xqdoc:name>
|
||||||
<xqdoc:type occurrence="*">item()</xqdoc:type>
|
<xqdoc:type occurrence="*">item()</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>empty-sequence()</xqdoc:type>
|
<xqdoc:type>empty-sequence()</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
<xqdoc:function arity="1">
|
<xqdoc:function arity="1">
|
||||||
<xqdoc:comment>
|
<xqdoc:comment>
|
||||||
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
|
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
|
||||||
<xqdoc:param>$src XML parameters <thumbnail><size width="100" ..</xqdoc:param>
|
<xqdoc:param>$src XML parameters <thumbnail><size width="100" ..</xqdoc:param>
|
||||||
<xqdoc:return>validation report</xqdoc:return>
|
<xqdoc:return>validation report</xqdoc:return>
|
||||||
</xqdoc:comment>
|
</xqdoc:comment>
|
||||||
<xqdoc:name>thumbnails:validation-report</xqdoc:name>
|
<xqdoc:name>thumbnails:validation-report</xqdoc:name>
|
||||||
<xqdoc:signature>declare function thumbnails:validation-report($src as item()*) as element(report)</xqdoc:signature>
|
<xqdoc:signature>declare function thumbnails:validation-report($src as item()*) as element(report)</xqdoc:signature>
|
||||||
<xqdoc:parameters>
|
<xqdoc:parameters>
|
||||||
<xqdoc:parameter>
|
<xqdoc:parameter>
|
||||||
<xqdoc:name>src</xqdoc:name>
|
<xqdoc:name>src</xqdoc:name>
|
||||||
<xqdoc:type occurrence="*">item()</xqdoc:type>
|
<xqdoc:type occurrence="*">item()</xqdoc:type>
|
||||||
</xqdoc:parameter>
|
</xqdoc:parameter>
|
||||||
</xqdoc:parameters>
|
</xqdoc:parameters>
|
||||||
<xqdoc:return>
|
<xqdoc:return>
|
||||||
<xqdoc:type>element(report)</xqdoc:type>
|
<xqdoc:type>element(report)</xqdoc:type>
|
||||||
</xqdoc:return>
|
</xqdoc:return>
|
||||||
</xqdoc:function>
|
</xqdoc:function>
|
||||||
</xqdoc:functions>
|
<xqdoc:function arity="0">
|
||||||
|
<xqdoc:name>thumbnails:schema-uri</xqdoc:name>
|
||||||
|
<xqdoc:signature>declare function thumbnails:schema-uri() as xs:anyURI</xqdoc:signature>
|
||||||
|
<xqdoc:return>
|
||||||
|
<xqdoc:type>xs:anyURI</xqdoc:type>
|
||||||
|
</xqdoc:return>
|
||||||
|
</xqdoc:function>
|
||||||
|
</xqdoc:functions>
|
||||||
</xqdoc:xqdoc>
|
</xqdoc:xqdoc>
|
Binary file not shown.
BIN
dist/thumbnailator-8.0.1.xar
vendored
Normal file
BIN
dist/thumbnailator-8.0.1.xar
vendored
Normal file
Binary file not shown.
BIN
lib/BaseX924.jar
Normal file
BIN
lib/BaseX924.jar
Normal file
Binary file not shown.
BIN
lib/BaseX945.jar
Normal file
BIN
lib/BaseX945.jar
Normal file
Binary file not shown.
|
@ -1,16 +1,16 @@
|
||||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||||
<jardesc>
|
<jardesc>
|
||||||
<jar path="ex-thumbnailator/src/main/content/thumbhelper-5.0.11.jar"/>
|
<jar path="ex-thumbnailator/src/main/content/thumbhelper-8.0.0.jar"/>
|
||||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ex-thumbnailator/makejar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
<options buildIfNeeded="true" compress="true" descriptionLocation="/ex-thumbnailator/makejar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||||
<selectedProjects/>
|
<selectedProjects/>
|
||||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||||
<sealing sealJar="false">
|
<sealing sealJar="false">
|
||||||
<packagesToSeal/>
|
<packagesToSeal/>
|
||||||
<packagesToUnSeal/>
|
<packagesToUnSeal/>
|
||||||
</sealing>
|
</sealing>
|
||||||
</manifest>
|
</manifest>
|
||||||
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
|
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
|
||||||
<javaElement handleIdentifier="=ex-thumbnailator/src\/java"/>
|
<javaElement handleIdentifier="=ex-thumbnailator/src\/java"/>
|
||||||
</selectedElements>
|
</selectedElements>
|
||||||
</jardesc>
|
</jardesc>
|
||||||
|
|
122
package.xml
122
package.xml
|
@ -1,53 +1,71 @@
|
||||||
<!-- @see http://cxan.org/faq#add-pkg -->
|
<!-- @see http://cxan.org/faq#add-pkg -->
|
||||||
<repo abbrev="ex-thumbnailator">
|
<repo abbrev="ex-thumbnailator">
|
||||||
<pkg abbrev="ex-thumbnailator" id="https://github.com/expkg-zone58/ex-thumbnailator">
|
<pkg abbrev="ex-thumbnailator" id="https://github.com/expkg-zone58/ex-thumbnailator">
|
||||||
<name>https://github.com/expkg-zone58/ex-thumbnailator</name>
|
<name>https://github.com/expkg-zone58/ex-thumbnailator</name>
|
||||||
<abstract>Create a thumbnail from a file path.</abstract>
|
<abstract>Create a thumbnail from a file path.</abstract>
|
||||||
<author id="coobird">coobird</author>
|
<author id="coobird">coobird</author>
|
||||||
<maintainer id="abunce">Andy Bunce</maintainer>
|
<maintainer id="abunce">Andy Bunce</maintainer>
|
||||||
<home>https://github.com/coobird/thumbnailator</home>
|
<home>https://github.com/coobird/thumbnailator</home>
|
||||||
<category id="libs">Library</category>
|
<category id="libs">Library</category>
|
||||||
<tag>image</tag>
|
<tag>image</tag>
|
||||||
<tag>resize</tag>
|
<tag>resize</tag>
|
||||||
<tag>graphic</tag>
|
<tag>graphic</tag>
|
||||||
<version num="4.1.4">
|
<version num="4.1.4">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="4.1.5">
|
<version num="4.1.5">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.0">
|
<version num="5.0.0">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.1">
|
<version num="5.0.1">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.2">
|
<version num="5.0.2">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.3">
|
<version num="5.0.3">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.4">
|
<version num="5.0.4">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.5">
|
<version num="5.0.5">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.7">
|
<version num="5.0.7">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.8">
|
<version num="5.0.8">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.9">
|
<version num="5.0.9">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.10">
|
<version num="5.0.10">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
<version num="5.0.11">
|
<version num="5.0.11">
|
||||||
<!-- generated: {fn:current-dateTime()} -->
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
</version>
|
</version>
|
||||||
</pkg>
|
<version num="6.0.0">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
<version num="6.0.1">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
<version num="6.0.2">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
<version num="7.0.0">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
<version num="7.0.1">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
<version num="8.0.1">
|
||||||
|
<!-- generated: {fn:current-dateTime()} -->
|
||||||
|
</version>
|
||||||
|
</pkg>
|
||||||
</repo>
|
</repo>
|
11
readme.md
11
readme.md
|
@ -1,10 +1,13 @@
|
||||||
# expkg-zone58:image.thumbnailator
|
# expkg-zone58:image.thumbnailator
|
||||||
|
|
||||||
An XQuery interface to the image thumbnail generator library
|
An XQuery interface to the image thumbnail generator library
|
||||||
[thumbnailator](https://github.com/coobird/thumbnailator) for BaseX 8.6.2+.
|
[thumbnailator](https://github.com/coobird/thumbnailator) for BaseX 9.4.5+.
|
||||||
|
|
||||||
Features size, scale, caption, rotate, flip, colorize, watermark. More details at [doc](doc/readme.md)
|
Features size, scale, caption, rotate, flip, colorize, watermark. More details at [doc](doc/readme.md)
|
||||||
|
|
||||||
|
## Versions
|
||||||
|
* `ex-thumbnailator` 8 requires Basex 9.4.5+
|
||||||
|
* uses `thumbnailator` 4.13
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Images are input and output as `xs:base64Binary` items. Inputs typically come from `fetch:binary`
|
Images are input and output as `xs:base64Binary` items. Inputs typically come from `fetch:binary`
|
||||||
|
@ -54,14 +57,14 @@ The schema for this XML is available at [task.xsd](./src/main/content/task.xsd)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
The library is packaged in the [EXpath](http://expath.org/spec/pkg) xar format with
|
The library is packaged in the [EXpath](http://expath.org/spec/pkg) xar format with
|
||||||
the thumbnailator jar included. See [releases](../releases) for installation instructions.
|
the thumbnailator jar included. See [releases](../../releases) for installation instructions.
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
`test.xqm` script uses the BaseX [Unit module](http://docs.basex.org/wiki/Unit_Module)
|
`test.xqm` script uses the BaseX [Unit module](http://docs.basex.org/wiki/Unit_Module)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
* ex-thumbnailator Copyright (c) 2016-2017, Andy Bunce. (Apache 2 License).
|
* ex-thumbnailator Copyright (c) 2013-2017, Andy Bunce. (Apache 2 License).
|
||||||
* thumbnailator Copyright (c) Chris Kroells (MIT License).
|
* thumbnailator Copyright (c) Chris Kroells (MIT License).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,25 +9,27 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import org.basex.data.Data;
|
||||||
import org.basex.io.IOContent;
|
import org.basex.io.IOContent;
|
||||||
import org.basex.query.QueryException;
|
import org.basex.query.QueryException;
|
||||||
import org.basex.query.QueryModule;
|
import org.basex.query.QueryModule;
|
||||||
//import org.basex.query.func.fn.FnTrace;
|
//import org.basex.query.func.fn.FnTrace;
|
||||||
import org.basex.query.value.item.B64Stream;
|
import org.basex.query.value.item.B64Lazy;
|
||||||
import org.basex.query.value.item.Dbl;
|
|
||||||
import org.basex.query.value.item.Int;
|
|
||||||
import org.basex.query.value.node.ANode;
|
import org.basex.query.value.node.ANode;
|
||||||
import org.basex.util.Token;
|
import org.basex.util.Token;
|
||||||
import org.basex.data.Data;
|
|
||||||
|
|
||||||
import net.coobird.thumbnailator.ThumbnailParameter;
|
import net.coobird.thumbnailator.ThumbnailParameter;
|
||||||
import net.coobird.thumbnailator.Thumbnailator;
|
import net.coobird.thumbnailator.Thumbnailator;
|
||||||
import net.coobird.thumbnailator.builders.ThumbnailParameterBuilder;
|
import net.coobird.thumbnailator.builders.ThumbnailParameterBuilder;
|
||||||
|
import net.coobird.thumbnailator.filters.Canvas;
|
||||||
|
import net.coobird.thumbnailator.filters.Caption;
|
||||||
|
import net.coobird.thumbnailator.filters.Colorize;
|
||||||
|
import net.coobird.thumbnailator.filters.Flip;
|
||||||
|
import net.coobird.thumbnailator.filters.ImageFilter;
|
||||||
import net.coobird.thumbnailator.filters.Pipeline;
|
import net.coobird.thumbnailator.filters.Pipeline;
|
||||||
import net.coobird.thumbnailator.filters.Rotation;
|
import net.coobird.thumbnailator.filters.Rotation;
|
||||||
import net.coobird.thumbnailator.filters.Watermark;
|
import net.coobird.thumbnailator.filters.Watermark;
|
||||||
|
@ -36,11 +38,6 @@ import net.coobird.thumbnailator.geometry.Position;
|
||||||
import net.coobird.thumbnailator.geometry.Positions;
|
import net.coobird.thumbnailator.geometry.Positions;
|
||||||
import net.coobird.thumbnailator.geometry.Region;
|
import net.coobird.thumbnailator.geometry.Region;
|
||||||
import net.coobird.thumbnailator.tasks.StreamThumbnailTask;
|
import net.coobird.thumbnailator.tasks.StreamThumbnailTask;
|
||||||
import net.coobird.thumbnailator.filters.Canvas;
|
|
||||||
import net.coobird.thumbnailator.filters.Caption;
|
|
||||||
import net.coobird.thumbnailator.filters.Colorize;
|
|
||||||
import net.coobird.thumbnailator.filters.Flip;
|
|
||||||
import net.coobird.thumbnailator.filters.ImageFilter;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BaseX Thumbnailator interface
|
* BaseX Thumbnailator interface
|
||||||
|
@ -51,7 +48,7 @@ import net.coobird.thumbnailator.filters.ImageFilter;
|
||||||
*/
|
*/
|
||||||
public class Thumbs extends QueryModule{
|
public class Thumbs extends QueryModule{
|
||||||
|
|
||||||
public B64Stream size(final B64Stream inputStream, final int width, final int height)
|
public B64Lazy size(final B64Lazy inputStream, final int width, final int height)
|
||||||
throws IOException, QueryException {
|
throws IOException, QueryException {
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
@ -59,10 +56,10 @@ public class Thumbs extends QueryModule{
|
||||||
builder.size(width, height);
|
builder.size(width, height);
|
||||||
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
|
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
|
||||||
Thumbnailator.createThumbnail(task);
|
Thumbnailator.createThumbnail(task);
|
||||||
return new B64Stream(new IOContent(os.toByteArray()), IOERR_X);
|
return new B64Lazy(new IOContent(os.toByteArray()), IOERR_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
public B64Stream scale(final B64Stream inputStream,
|
public B64Lazy scale(final B64Lazy inputStream,
|
||||||
final double xscale, final double yscale)
|
final double xscale, final double yscale)
|
||||||
throws IOException, QueryException {
|
throws IOException, QueryException {
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
||||||
|
@ -71,26 +68,24 @@ public class Thumbs extends QueryModule{
|
||||||
builder.scale(xscale, yscale);
|
builder.scale(xscale, yscale);
|
||||||
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
|
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
|
||||||
Thumbnailator.createThumbnail(task);
|
Thumbnailator.createThumbnail(task);
|
||||||
return new B64Stream(new IOContent(os.toByteArray()), IOERR_X);
|
return new B64Lazy(new IOContent(os.toByteArray()), IOERR_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
public B64Stream task(final B64Stream inputStream, final ANode thumbnail)
|
public B64Lazy task(final B64Lazy inputStream, final ANode thumbnail)
|
||||||
throws IOException, QueryException {
|
throws IOException, QueryException {
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
ThumbnailParameter param = fromNode(thumbnail);
|
ThumbnailParameter param = fromNode(thumbnail);
|
||||||
StreamThumbnailTask task = new StreamThumbnailTask(param, is, os);
|
StreamThumbnailTask task = new StreamThumbnailTask(param, is, os);
|
||||||
Thumbnailator.createThumbnail(task);
|
Thumbnailator.createThumbnail(task);
|
||||||
return new B64Stream(new IOContent(os.toByteArray()), IOERR_X);
|
return new B64Lazy(new IOContent(os.toByteArray()), IOERR_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build parameters from XML
|
// build parameters from XML
|
||||||
ThumbnailParameter fromNode(final ANode node) throws QueryException, IOException {
|
ThumbnailParameter fromNode(final ANode node) throws QueryException, IOException {
|
||||||
ThumbnailParameterBuilder builder = new ThumbnailParameterBuilder();
|
ThumbnailParameterBuilder builder = new ThumbnailParameterBuilder();
|
||||||
|
for(final ANode element : node.childIter()) {
|
||||||
Iterator<ANode> itr = node.children().iterator();
|
|
||||||
while (itr.hasNext()) {
|
|
||||||
ANode element = itr.next();
|
|
||||||
if (element.kind() == Data.ELEM) {
|
if (element.kind() == Data.ELEM) {
|
||||||
String name = Token.string(element.name());
|
String name = Token.string(element.name());
|
||||||
// FnTrace.trace(name.getBytes(), "element: ".getBytes(), queryContext);
|
// FnTrace.trace(name.getBytes(), "element: ".getBytes(), queryContext);
|
||||||
|
@ -134,8 +129,8 @@ public class Thumbs extends QueryModule{
|
||||||
void region(final ThumbnailParameterBuilder builder, final ANode node)
|
void region(final ThumbnailParameterBuilder builder, final ANode node)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
|
|
||||||
int width = (int) Int.parse(node.attribute("width"), null);
|
int width = Utils.attrib(node,"width", 80);
|
||||||
int height = (int) Int.parse(node.attribute("height"), null);
|
int height = Utils.attrib(node,"height", 80);
|
||||||
Dimension d = new Dimension(width, height);
|
Dimension d = new Dimension(width, height);
|
||||||
Position pos = Utils.position(node, "position", Positions.CENTER);
|
Position pos = Utils.position(node, "position", Positions.CENTER);
|
||||||
Region r = new Region(pos, new AbsoluteSize(d));
|
Region r = new Region(pos, new AbsoluteSize(d));
|
||||||
|
@ -157,8 +152,8 @@ public class Thumbs extends QueryModule{
|
||||||
|
|
||||||
void size(final ThumbnailParameterBuilder builder, final ANode node)
|
void size(final ThumbnailParameterBuilder builder, final ANode node)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
int width = (int) Int.parse(node.attribute("width"), null);
|
int width = Utils.attrib(node, "width", 80);
|
||||||
int height = (int) Int.parse(node.attribute("height"), null);
|
int height = Utils.attrib(node, "height", 80);
|
||||||
builder.size(width, height);
|
builder.size(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +166,7 @@ public class Thumbs extends QueryModule{
|
||||||
|
|
||||||
List<ImageFilter> filters(final ANode filters) throws QueryException, IOException {
|
List<ImageFilter> filters(final ANode filters) throws QueryException, IOException {
|
||||||
Pipeline pipeline = new Pipeline();
|
Pipeline pipeline = new Pipeline();
|
||||||
Iterator<ANode> itr = filters.children().iterator();
|
for(final ANode node : filters.childIter()) {
|
||||||
while (itr.hasNext()) {
|
|
||||||
ANode node = itr.next();
|
|
||||||
if (node.kind() == Data.ELEM) {
|
if (node.kind() == Data.ELEM) {
|
||||||
switch (Token.string(node.name())) {
|
switch (Token.string(node.name())) {
|
||||||
|
|
||||||
|
@ -213,7 +206,7 @@ public class Thumbs extends QueryModule{
|
||||||
throws IOException, QueryException {
|
throws IOException, QueryException {
|
||||||
ImageFilter filter;
|
ImageFilter filter;
|
||||||
Position pos;
|
Position pos;
|
||||||
String src = Token.string(node.attribute("src"));
|
String src = Utils.attrib(node, "src", "");
|
||||||
pos = Utils.position(node, "position", Positions.BOTTOM_RIGHT);
|
pos = Utils.position(node, "position", Positions.BOTTOM_RIGHT);
|
||||||
BufferedImage watermarkImg = ImageIO.read(new File(src));
|
BufferedImage watermarkImg = ImageIO.read(new File(src));
|
||||||
filter = new Watermark(pos, watermarkImg, Utils.attrib(node, "alpha", 0.5f));
|
filter = new Watermark(pos, watermarkImg, Utils.attrib(node, "alpha", 0.5f));
|
||||||
|
@ -222,13 +215,13 @@ public class Thumbs extends QueryModule{
|
||||||
|
|
||||||
private void rotate(final Pipeline pipeline, final ANode node)
|
private void rotate(final Pipeline pipeline, final ANode node)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
double angle = (double) Dbl.parse(node.attribute("angle"), null);
|
double angle = (double) Utils.attrib(node, "angle", 0);
|
||||||
pipeline.add(Rotation.newRotator(angle));
|
pipeline.add(Rotation.newRotator(angle));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flip(final Pipeline pipeline, final ANode node) {
|
private void flip(final Pipeline pipeline, final ANode node) throws QueryException {
|
||||||
ImageFilter filter;
|
ImageFilter filter;
|
||||||
String axis = Token.string(node.attribute("axis"));
|
String axis = Utils.attrib(node, "axis", "vertical");
|
||||||
// FnTrace.trace(axis.getBytes(), "FLIP: ".getBytes(), queryContext);
|
// FnTrace.trace(axis.getBytes(), "FLIP: ".getBytes(), queryContext);
|
||||||
filter = axis.equalsIgnoreCase("vertical") ? Flip.VERTICAL : Flip.HORIZONTAL;
|
filter = axis.equalsIgnoreCase("vertical") ? Flip.VERTICAL : Flip.HORIZONTAL;
|
||||||
pipeline.add(filter);
|
pipeline.add(filter);
|
||||||
|
@ -247,8 +240,8 @@ public class Thumbs extends QueryModule{
|
||||||
ImageFilter filter;
|
ImageFilter filter;
|
||||||
String color;
|
String color;
|
||||||
Position pos;
|
Position pos;
|
||||||
int width = (int) Int.parse(node.attribute("width"), null);
|
int width = Utils.attrib(node, "width", 80);
|
||||||
int height = (int) Int.parse(node.attribute("height"), null);
|
int height = Utils.attrib(node, "height", 80);
|
||||||
color = Utils.attrib(node, "color", "black");
|
color = Utils.attrib(node, "color", "black");
|
||||||
pos = Utils.position(node, "position", Positions.CENTER);
|
pos = Utils.position(node, "position", Positions.CENTER);
|
||||||
filter = new Canvas(width, height, pos, false, Utils.stringToColor(color));
|
filter = new Canvas(width, height, pos, false, Utils.stringToColor(color));
|
||||||
|
|
|
@ -2,11 +2,13 @@ package org.expkgzone58.image;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import org.basex.query.QueryException;
|
import org.basex.query.QueryException;
|
||||||
import org.basex.query.value.item.Bln;
|
import org.basex.query.value.item.Bln;
|
||||||
import org.basex.query.value.item.Dbl;
|
import org.basex.query.value.item.Dbl;
|
||||||
import org.basex.query.value.item.Int;
|
import org.basex.query.value.item.Int;
|
||||||
|
import org.basex.query.value.item.Item;
|
||||||
import org.basex.query.value.node.ANode;
|
import org.basex.query.value.node.ANode;
|
||||||
import org.basex.util.Token;
|
import org.basex.util.Token;
|
||||||
|
|
||||||
|
@ -19,31 +21,31 @@ public final class Utils {
|
||||||
// get value from attribute with default
|
// get value from attribute with default
|
||||||
public static String attrib(final ANode element, final String name, final String def)
|
public static String attrib(final ANode element, final String name, final String def)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
byte[] at = element.attribute(name);
|
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
|
||||||
return (at == null) ? def : Token.string(at);
|
return (at == null) ? def : Token.string(at);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float attrib(final ANode element, final String name, final float def)
|
public static float attrib(final ANode element, final String name, final float def)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
byte[] at = element.attribute(name);
|
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
|
||||||
return (at == null) ? def : (float) Dbl.parse(at, null);
|
return (at == null) ? def : (float) Dbl.parse(at, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int attrib(final ANode element, final String name, final int def)
|
public static int attrib(final ANode element, final String name, final int def)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
byte[] at = element.attribute(name);
|
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
|
||||||
return (at == null) ? def : (int) Int.parse(at, null);
|
return (at == null) ? def : Token.toInt(at);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean attrib(final ANode element, final String name, final boolean def)
|
public static boolean attrib(final ANode element, final String name, final boolean def)
|
||||||
throws QueryException {
|
throws QueryException {
|
||||||
byte[] at = element.attribute(name);
|
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
|
||||||
return (at == null) ? def : (boolean) Bln.parse(at, null);
|
return (boolean) ((at == null) ? def : Bln.parse(at));
|
||||||
}
|
}
|
||||||
|
|
||||||
// e.g. TOP_LEFT
|
// e.g. TOP_LEFT
|
||||||
public static Position position(final ANode element, final String name, final Position def) {
|
public static Position position(final ANode element, final String name, final Position def) {
|
||||||
byte[] at = element.attribute(name);
|
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
|
||||||
return (at == null) ? def : Positions.valueOf(Token.string(at));
|
return (at == null) ? def : Positions.valueOf(Token.string(at));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<package xmlns="http://www.basex.org/modules/pkg">
|
<package xmlns="http://www.basex.org/modules/pkg">
|
||||||
<jar>thumbhelper-5.0.11.jar</jar>
|
<jar>thumbhelper-8.0.0.jar</jar>
|
||||||
<jar>thumbnailator-0.4.8.jar</jar>
|
<jar>thumbnailator-0.4.13.jar</jar>
|
||||||
<class>org.expkgzone58.image.Thumbs</class>
|
<class>org.expkgzone58.image.Thumbs</class>
|
||||||
</package>
|
</package>
|
||||||
|
|
Binary file not shown.
BIN
src/main/content/thumbhelper-8.0.0.jar
Normal file
BIN
src/main/content/thumbhelper-8.0.0.jar
Normal file
Binary file not shown.
BIN
src/main/content/thumbnailator-0.4.13.jar
Normal file
BIN
src/main/content/thumbnailator-0.4.13.jar
Normal file
Binary file not shown.
Binary file not shown.
|
@ -2,10 +2,11 @@ xquery version "3.1" encoding "UTF-8";
|
||||||
(:~ Generate image thumbnails using the thumbnailator library.
|
(:~ Generate image thumbnails using the thumbnailator library.
|
||||||
: @see https://github.com/coobird/thumbnailator
|
: @see https://github.com/coobird/thumbnailator
|
||||||
: @author andy bunce
|
: @author andy bunce
|
||||||
: @version 0.5
|
: @version 0.6
|
||||||
:)
|
:)
|
||||||
module namespace thumbnails = 'expkg-zone58:image.thumbnailator';
|
module namespace thumbnails = 'expkg-zone58:image.thumbnailator';
|
||||||
import module namespace Thumbs = "org.expkgzone58.image.Thumbs";
|
import module namespace Thumbs = "org.expkgzone58.image.Thumbs";
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
: generate scaled version of source image with maximum dimension of size
|
: generate scaled version of source image with maximum dimension of size
|
||||||
: @param $source base64Binary (streamed?) e.g from `fetch:binary`
|
: @param $source base64Binary (streamed?) e.g from `fetch:binary`
|
||||||
|
@ -84,4 +85,10 @@ declare function thumbnails:validation-report($src)
|
||||||
as element(report)
|
as element(report)
|
||||||
{
|
{
|
||||||
validate:xsd-report($src,"task.xsd")
|
validate:xsd-report($src,"task.xsd")
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function thumbnails:schema-uri()
|
||||||
|
as xs:anyURI
|
||||||
|
{
|
||||||
|
resolve-uri("task.xsd")
|
||||||
};
|
};
|
|
@ -1,8 +1,8 @@
|
||||||
<package xmlns="http://expath.org/ns/pkg" name="https://github.com/expkg-zone58/ex-thumbnailator"
|
<package xmlns="http://expath.org/ns/pkg" name="https://github.com/expkg-zone58/ex-thumbnailator"
|
||||||
abbrev="thumbnailator" version="5.0.11" spec="1.0">
|
abbrev="thumbnailator" version="8.0.1" spec="1.0">
|
||||||
|
|
||||||
<title>An XQuery interface to thumbnailator the thumbnail generator library.</title>
|
<title>An XQuery interface to thumbnailator the thumbnail generator library.</title>
|
||||||
<dependency processor="basex" />
|
|
||||||
<xquery>
|
<xquery>
|
||||||
<namespace>expkg-zone58:image.thumbnailator</namespace>
|
<namespace>expkg-zone58:image.thumbnailator</namespace>
|
||||||
<file>thumbnailator.xqm</file>
|
<file>thumbnailator.xqm</file>
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
(:~
|
(:~
|
||||||
:examples of constrain use
|
:examples of constrain use
|
||||||
|
: generate 8 files showing all perms of aspect,fit,exif
|
||||||
:)
|
:)
|
||||||
import module namespace t="expkg-zone58:image.thumbnailator";
|
import module namespace t="expkg-zone58:image.thumbnailator";
|
||||||
declare variable $file-base:=file:parent(static-base-uri());
|
declare variable $file-base:=file:parent(static-base-uri());
|
||||||
declare variable $watermark:="C:\Users\andy\git\ex-thumbnailator\src\test\resources\icon.gif";
|
declare variable $watermark:="C:\Users\andy\git\ex-thumbnailator\src\test\resources\icon.gif";
|
||||||
declare variable $src:=file:resolve-path("resources/A34283.jpg",$file-base);
|
declare variable $src:=file:resolve-path("resources/A34283.jpg",$file-base);
|
||||||
|
|
||||||
declare function local:wi($data as xs:base64Binary,$filename as xs:string)
|
declare function local:wi($data as xs:base64Binary,$filename as xs:string)
|
||||||
{
|
{
|
||||||
file:write-binary(file:resolve-path($filename,$file-base),$data)
|
file:write-binary(file:resolve-path($filename,$file-base),$data)
|
||||||
};
|
};
|
||||||
|
|
||||||
declare function local:constrain($aspect as xs:boolean,$fit as xs:boolean,$exif as xs:boolean)
|
declare function local:constrain($aspect as xs:boolean,$fit as xs:boolean,$exif as xs:boolean)
|
||||||
{
|
{
|
||||||
<constrain aspect="{$aspect}" fit="{$fit}" exif="{$exif}"/>
|
<constrain aspect="{$aspect}" fit="{$fit}" exif="{$exif}"/>
|
||||||
};
|
};
|
||||||
|
|
||||||
let $s:=function($b){if($b) then ".+" else ".-"}
|
let $s:=function($b){if($b) then ".+" else ".-"}
|
||||||
let $img:= fetch:binary($src)
|
let $img:= fetch:binary($src)
|
||||||
let $ft:=(false(),true())
|
let $ft:=(false(),true())
|
37
src/test/inset.xq
Normal file
37
src/test/inset.xq
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
(:~
|
||||||
|
:examples of inset use
|
||||||
|
:)
|
||||||
|
import module namespace t="expkg-zone58:image.thumbnailator";
|
||||||
|
|
||||||
|
declare variable $watermark:=local:path("resources\icon.gif");
|
||||||
|
declare variable $src:=local:path("resources/A34283.jpg");
|
||||||
|
|
||||||
|
declare function local:path($name){
|
||||||
|
file:resolve-path($name,file:base-dir())
|
||||||
|
};
|
||||||
|
declare function local:save($data as xs:base64Binary,$filename as xs:string)
|
||||||
|
{
|
||||||
|
file:write-binary(local:path($filename),$data)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let $img:= fetch:binary($src)
|
||||||
|
|
||||||
|
let $task:=<thumbnail>
|
||||||
|
<size width="300" height="300"/>
|
||||||
|
<constrain fit="true"/>
|
||||||
|
<filters>
|
||||||
|
<rotate angle="45"/>
|
||||||
|
<caption size="60" color="white" position="CENTER">DRAFT</caption>
|
||||||
|
<rotate angle="-45"/>
|
||||||
|
<canvas height="300" width="300" color="lightGray" position="CENTER"/>
|
||||||
|
<caption size="30" color="black" insets="10"
|
||||||
|
position="TOP_CENTER">Caption insets = 10</caption>
|
||||||
|
<watermark src="{$watermark}" alpha="1" position="BOTTOM_RIGHT"/>
|
||||||
|
<caption size="30" color="black" insets="-3"
|
||||||
|
position="BOTTOM_LEFT">BOTTOM_LEFT -3</caption>
|
||||||
|
|
||||||
|
</filters>
|
||||||
|
<output format="gif"/>
|
||||||
|
</thumbnail>
|
||||||
|
return t:task($img,$task) => local:save("resources/" || "inset.gif")
|
BIN
src/test/resources/DSCF0758.JPG
Normal file
BIN
src/test/resources/DSCF0758.JPG
Normal file
Binary file not shown.
After (image error) Size: 151 KiB |
BIN
src/test/resources/inset.gif
Normal file
BIN
src/test/resources/inset.gif
Normal file
Binary file not shown.
After ![]() (image error) Size: 33 KiB |
Binary file not shown.
Before ![]() (image error) Size: 32 KiB After ![]() (image error) Size: 31 KiB ![]() ![]() |
|
@ -1,4 +1,4 @@
|
||||||
import module namespace t="expkg-zone58:image.thumbnailator";
|
import module namespace t="expkg-zone58:image.thumbnailator" at "../main/content/thumbnailator.xqm";
|
||||||
|
|
||||||
declare variable $pic1:=resolve-uri("resources/simple.jpg");
|
declare variable $pic1:=resolve-uri("resources/simple.jpg");
|
||||||
declare variable $picr:=resolve-uri("resources/result2.jpg");
|
declare variable $picr:=resolve-uri("resources/result2.jpg");
|
||||||
|
|
|
@ -29,7 +29,7 @@ declare
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
(:~ make a thumbnail :)
|
(:~ validate a task :)
|
||||||
declare
|
declare
|
||||||
%unit:test
|
%unit:test
|
||||||
function test:validate() {
|
function test:validate() {
|
||||||
|
|
|
@ -32,7 +32,7 @@ declare %updating function write-xqdoc($path,$src,$dest){
|
||||||
case "application/xquery"
|
case "application/xquery"
|
||||||
return file:write(
|
return file:write(
|
||||||
fn:resolve-uri($path || ".xml",$dest),
|
fn:resolve-uri($path || ".xml",$dest),
|
||||||
inspect:xqdoc($url)
|
inspect:xqdoc($url)
|
||||||
)
|
)
|
||||||
default
|
default
|
||||||
return ()
|
return ()
|
||||||
|
|
Loading…
Add table
Reference in a new issue