Compare commits

...

10 commits

Author SHA1 Message Date
e3778bb3ba add .drone
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-05-22 22:18:26 +01:00
7138b46f65 update readme 2021-05-22 22:11:08 +01:00
78e8f1b28a [MOD] update to support BaseX 9.4.5 and use thumbnailator 4.13 2021-02-16 23:05:20 +00:00
andy
460987bfec rebuild for Basex9.2.4 2019-10-31 21:51:10 +00:00
45f06ca4e2 [fix] Node api changed in basex 9 released 2018-06-29 19:16:33 +01:00
a6a38601fd Merge branch 'master' of https://github.com/expkg-zone58/ex-thumbnailator 2017-12-29 12:04:46 +00:00
9294164247 basex v9 stream->lazy 2017-11-24 23:48:45 +00:00
15560b26a3 Merge pull request #1 from expkg-zone58/dev
branch test
2017-07-28 12:06:59 +01:00
bb089e9a60 branch test 2017-07-28 12:04:50 +01:00
1e74f304f3 readme link 2017-04-30 11:04:04 +01:00
27 changed files with 399 additions and 318 deletions

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Program Files (x86)/BaseX/BaseX.jar" sourcepath="/basex-core/src"/>
<classpathentry kind="lib" path="src/main/content/thumbnailator-0.4.8.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/BaseX945.jar"/>
<classpathentry kind="lib" path="src/main/content/thumbnailator-0.4.13.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

10
.drone.yml Normal file
View file

@ -0,0 +1,10 @@
kind: pipeline
type: docker
name: default
steps:
- name: test
image: golang
commands:
- go build
- go test

View file

@ -1,187 +1,194 @@
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0">
<xqdoc:control>
<xqdoc:date>2017-04-29T22:28:45.705+01:00</xqdoc:date>
<xqdoc:version>1.1</xqdoc:version>
</xqdoc:control>
<xqdoc:module type="library">
<xqdoc:uri>expkg-zone58:image.thumbnailator</xqdoc:uri>
<xqdoc:name>thumbnailator.xqm</xqdoc:name>
<xqdoc:comment>
<xqdoc:description>Generate image thumbnails using the thumbnailator library.</xqdoc:description>
<xqdoc:see>https://github.com/coobird/thumbnailator</xqdoc:see>
<xqdoc:author>andy bunce</xqdoc:author>
<xqdoc:version>0.5</xqdoc:version>
</xqdoc:comment>
</xqdoc:module>
<xqdoc:namespaces>
<xqdoc:namespace prefix="thumbnails" uri="expkg-zone58:image.thumbnailator"/>
<xqdoc:namespace prefix="Thumbs" uri="org.expkgzone58.image.Thumbs"/>
</xqdoc:namespaces>
<xqdoc:imports>
<xqdoc:import type="library">
<xqdoc:uri>org.expkgzone58.image.Thumbs</xqdoc:uri>
</xqdoc:import>
</xqdoc:imports>
<xqdoc:variables/>
<xqdoc:functions>
<xqdoc:function arity="2">
<xqdoc:comment>
<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:return>base64Binary for thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>size</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="3">
<xqdoc:comment>
<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:return>base64Binary for thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>width</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>height</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="2">
<xqdoc:comment>
<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:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>scale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="3">
<xqdoc:comment>
<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:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>xscale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>yscale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="2">
<xqdoc:comment>
<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>$task XML parameters &lt;task&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>task</xqdoc:name>
<xqdoc:type>element(thumbnail)</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="1">
<xqdoc:comment>
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
<xqdoc:param>$src XML parameters &lt;thumbnail&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>empty-sequence or error</xqdoc:return>
<xqdoc:error>BXVA0001: the validation fails.</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>BXVA0004: no validator is found for the specified version.</xqdoc:error>
</xqdoc:comment>
<xqdoc:name>thumbnails:validate</xqdoc:name>
<xqdoc:signature>declare function thumbnails:validate($src as item()*) as empty-sequence()</xqdoc:signature>
<xqdoc:parameters>
<xqdoc:parameter>
<xqdoc:name>src</xqdoc:name>
<xqdoc:type occurrence="*">item()</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>empty-sequence()</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="1">
<xqdoc:comment>
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
<xqdoc:param>$src XML parameters &lt;thumbnail&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>validation report</xqdoc:return>
</xqdoc:comment>
<xqdoc:name>thumbnails:validation-report</xqdoc:name>
<xqdoc:signature>declare function thumbnails:validation-report($src as item()*) as element(report)</xqdoc:signature>
<xqdoc:parameters>
<xqdoc:parameter>
<xqdoc:name>src</xqdoc:name>
<xqdoc:type occurrence="*">item()</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>element(report)</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
</xqdoc:functions>
<xqdoc:xqdoc xmlns:xqdoc="http://www.xqdoc.org/1.0">
<xqdoc:control>
<xqdoc:date>2021-02-16T23:01:20.669Z</xqdoc:date>
<xqdoc:version>1.1</xqdoc:version>
</xqdoc:control>
<xqdoc:module type="library">
<xqdoc:uri>expkg-zone58:image.thumbnailator</xqdoc:uri>
<xqdoc:name>thumbnailator.xqm</xqdoc:name>
<xqdoc:comment>
<xqdoc:description>Generate image thumbnails using the thumbnailator library.</xqdoc:description>
<xqdoc:see>https://github.com/coobird/thumbnailator</xqdoc:see>
<xqdoc:author>andy bunce</xqdoc:author>
<xqdoc:version>0.6</xqdoc:version>
</xqdoc:comment>
</xqdoc:module>
<xqdoc:imports>
<xqdoc:import type="library">
<xqdoc:uri>org.expkgzone58.image.Thumbs</xqdoc:uri>
</xqdoc:import>
</xqdoc:imports>
<xqdoc:namespaces>
<xqdoc:namespace prefix="thumbnails" uri="expkg-zone58:image.thumbnailator"/>
<xqdoc:namespace prefix="Thumbs" uri="org.expkgzone58.image.Thumbs"/>
</xqdoc:namespaces>
<xqdoc:variables/>
<xqdoc:functions>
<xqdoc:function arity="2">
<xqdoc:comment>
<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:return>base64Binary for thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>size</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="3">
<xqdoc:comment>
<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:return>base64Binary for thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>width</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>height</xqdoc:name>
<xqdoc:type>xs:integer</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="2">
<xqdoc:comment>
<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:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>scale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="3">
<xqdoc:comment>
<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:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>xscale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>yscale</xqdoc:name>
<xqdoc:type>xs:double</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="2">
<xqdoc:comment>
<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>$task XML parameters &lt;task&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>the thumbnail</xqdoc:return>
</xqdoc:comment>
<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:parameters>
<xqdoc:parameter>
<xqdoc:name>source</xqdoc:name>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:parameter>
<xqdoc:parameter>
<xqdoc:name>task</xqdoc:name>
<xqdoc:type>element(thumbnail)</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>xs:base64Binary</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="1">
<xqdoc:comment>
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
<xqdoc:param>$src XML parameters &lt;thumbnail&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>empty-sequence or error</xqdoc:return>
<xqdoc:error>BXVA0001: the validation fails.</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>BXVA0004: no validator is found for the specified version.</xqdoc:error>
</xqdoc:comment>
<xqdoc:name>thumbnails:validate</xqdoc:name>
<xqdoc:signature>declare function thumbnails:validate($src as item()*) as empty-sequence()</xqdoc:signature>
<xqdoc:parameters>
<xqdoc:parameter>
<xqdoc:name>src</xqdoc:name>
<xqdoc:type occurrence="*">item()</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>empty-sequence()</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<xqdoc:function arity="1">
<xqdoc:comment>
<xqdoc:description>validate task thumbnail XML against schema</xqdoc:description>
<xqdoc:param>$src XML parameters &lt;thumbnail&gt;&lt;size width="100" ..</xqdoc:param>
<xqdoc:return>validation report</xqdoc:return>
</xqdoc:comment>
<xqdoc:name>thumbnails:validation-report</xqdoc:name>
<xqdoc:signature>declare function thumbnails:validation-report($src as item()*) as element(report)</xqdoc:signature>
<xqdoc:parameters>
<xqdoc:parameter>
<xqdoc:name>src</xqdoc:name>
<xqdoc:type occurrence="*">item()</xqdoc:type>
</xqdoc:parameter>
</xqdoc:parameters>
<xqdoc:return>
<xqdoc:type>element(report)</xqdoc:type>
</xqdoc:return>
</xqdoc:function>
<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>

BIN
dist/thumbnailator-8.0.1.xar vendored Normal file

Binary file not shown.

BIN
lib/BaseX924.jar Normal file

Binary file not shown.

BIN
lib/BaseX945.jar Normal file

Binary file not shown.

View file

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc>
<jar path="ex-thumbnailator/src/main/content/thumbhelper-5.0.11.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"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
<javaElement handleIdentifier="=ex-thumbnailator/src\/java"/>
</selectedElements>
</jardesc>
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc>
<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"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
<javaElement handleIdentifier="=ex-thumbnailator/src\/java"/>
</selectedElements>
</jardesc>

View file

@ -1,53 +1,71 @@
<!-- @see http://cxan.org/faq#add-pkg -->
<repo abbrev="ex-thumbnailator">
<pkg abbrev="ex-thumbnailator" id="https://github.com/expkg-zone58/ex-thumbnailator">
<name>https://github.com/expkg-zone58/ex-thumbnailator</name>
<abstract>Create a thumbnail from a file path.</abstract>
<author id="coobird">coobird</author>
<maintainer id="abunce">Andy Bunce</maintainer>
<home>https://github.com/coobird/thumbnailator</home>
<category id="libs">Library</category>
<tag>image</tag>
<tag>resize</tag>
<tag>graphic</tag>
<version num="4.1.4">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="4.1.5">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.0">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.1">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.2">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.3">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.4">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.5">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.7">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.8">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.9">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.10">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.11">
<!-- generated: {fn:current-dateTime()} -->
</version>
</pkg>
<!-- @see http://cxan.org/faq#add-pkg -->
<repo abbrev="ex-thumbnailator">
<pkg abbrev="ex-thumbnailator" id="https://github.com/expkg-zone58/ex-thumbnailator">
<name>https://github.com/expkg-zone58/ex-thumbnailator</name>
<abstract>Create a thumbnail from a file path.</abstract>
<author id="coobird">coobird</author>
<maintainer id="abunce">Andy Bunce</maintainer>
<home>https://github.com/coobird/thumbnailator</home>
<category id="libs">Library</category>
<tag>image</tag>
<tag>resize</tag>
<tag>graphic</tag>
<version num="4.1.4">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="4.1.5">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.0">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.1">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.2">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.3">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.4">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.5">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.7">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.8">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.9">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.10">
<!-- generated: {fn:current-dateTime()} -->
</version>
<version num="5.0.11">
<!-- generated: {fn:current-dateTime()} -->
</version>
<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>

View file

@ -1,10 +1,13 @@
# expkg-zone58:image.thumbnailator
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)
## 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`
@ -54,14 +57,14 @@ The schema for this XML is available at [task.xsd](./src/main/content/task.xsd)
## Installation
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
`test.xqm` script uses the BaseX [Unit module](http://docs.basex.org/wiki/Unit_Module)
## 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).

View file

@ -9,25 +9,27 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.imageio.ImageIO;
import org.basex.data.Data;
import org.basex.io.IOContent;
import org.basex.query.QueryException;
import org.basex.query.QueryModule;
//import org.basex.query.func.fn.FnTrace;
import org.basex.query.value.item.B64Stream;
import org.basex.query.value.item.Dbl;
import org.basex.query.value.item.Int;
import org.basex.query.value.item.B64Lazy;
import org.basex.query.value.node.ANode;
import org.basex.util.Token;
import org.basex.data.Data;
import net.coobird.thumbnailator.ThumbnailParameter;
import net.coobird.thumbnailator.Thumbnailator;
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.Rotation;
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.Region;
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
@ -51,7 +48,7 @@ import net.coobird.thumbnailator.filters.ImageFilter;
*/
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 {
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
ByteArrayOutputStream os = new ByteArrayOutputStream();
@ -59,10 +56,10 @@ public class Thumbs extends QueryModule{
builder.size(width, height);
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
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)
throws IOException, QueryException {
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
@ -71,26 +68,24 @@ public class Thumbs extends QueryModule{
builder.scale(xscale, yscale);
StreamThumbnailTask task = new StreamThumbnailTask(builder.build(), is, os);
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 {
ByteArrayInputStream is = new ByteArrayInputStream(inputStream.binary(null));
ByteArrayOutputStream os = new ByteArrayOutputStream();
ThumbnailParameter param = fromNode(thumbnail);
StreamThumbnailTask task = new StreamThumbnailTask(param, is, os);
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
ThumbnailParameter fromNode(final ANode node) throws QueryException, IOException {
ThumbnailParameterBuilder builder = new ThumbnailParameterBuilder();
Iterator<ANode> itr = node.children().iterator();
while (itr.hasNext()) {
ANode element = itr.next();
for(final ANode element : node.childIter()) {
if (element.kind() == Data.ELEM) {
String name = Token.string(element.name());
// FnTrace.trace(name.getBytes(), "element: ".getBytes(), queryContext);
@ -134,8 +129,8 @@ public class Thumbs extends QueryModule{
void region(final ThumbnailParameterBuilder builder, final ANode node)
throws QueryException {
int width = (int) Int.parse(node.attribute("width"), null);
int height = (int) Int.parse(node.attribute("height"), null);
int width = Utils.attrib(node,"width", 80);
int height = Utils.attrib(node,"height", 80);
Dimension d = new Dimension(width, height);
Position pos = Utils.position(node, "position", Positions.CENTER);
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)
throws QueryException {
int width = (int) Int.parse(node.attribute("width"), null);
int height = (int) Int.parse(node.attribute("height"), null);
int width = Utils.attrib(node, "width", 80);
int height = Utils.attrib(node, "height", 80);
builder.size(width, height);
}
@ -171,9 +166,7 @@ public class Thumbs extends QueryModule{
List<ImageFilter> filters(final ANode filters) throws QueryException, IOException {
Pipeline pipeline = new Pipeline();
Iterator<ANode> itr = filters.children().iterator();
while (itr.hasNext()) {
ANode node = itr.next();
for(final ANode node : filters.childIter()) {
if (node.kind() == Data.ELEM) {
switch (Token.string(node.name())) {
@ -213,7 +206,7 @@ public class Thumbs extends QueryModule{
throws IOException, QueryException {
ImageFilter filter;
Position pos;
String src = Token.string(node.attribute("src"));
String src = Utils.attrib(node, "src", "");
pos = Utils.position(node, "position", Positions.BOTTOM_RIGHT);
BufferedImage watermarkImg = ImageIO.read(new File(src));
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)
throws QueryException {
double angle = (double) Dbl.parse(node.attribute("angle"), null);
double angle = (double) Utils.attrib(node, "angle", 0);
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;
String axis = Token.string(node.attribute("axis"));
String axis = Utils.attrib(node, "axis", "vertical");
// FnTrace.trace(axis.getBytes(), "FLIP: ".getBytes(), queryContext);
filter = axis.equalsIgnoreCase("vertical") ? Flip.VERTICAL : Flip.HORIZONTAL;
pipeline.add(filter);
@ -247,8 +240,8 @@ public class Thumbs extends QueryModule{
ImageFilter filter;
String color;
Position pos;
int width = (int) Int.parse(node.attribute("width"), null);
int height = (int) Int.parse(node.attribute("height"), null);
int width = Utils.attrib(node, "width", 80);
int height = Utils.attrib(node, "height", 80);
color = Utils.attrib(node, "color", "black");
pos = Utils.position(node, "position", Positions.CENTER);
filter = new Canvas(width, height, pos, false, Utils.stringToColor(color));

View file

@ -2,11 +2,13 @@ package org.expkgzone58.image;
import java.awt.Color;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import org.basex.query.QueryException;
import org.basex.query.value.item.Bln;
import org.basex.query.value.item.Dbl;
import org.basex.query.value.item.Int;
import org.basex.query.value.item.Item;
import org.basex.query.value.node.ANode;
import org.basex.util.Token;
@ -19,31 +21,31 @@ public final class Utils {
// get value from attribute with default
public static String attrib(final ANode element, final String name, final String def)
throws QueryException {
byte[] at = element.attribute(name);
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
return (at == null) ? def : Token.string(at);
}
public static float attrib(final ANode element, final String name, final float def)
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);
}
public static int attrib(final ANode element, final String name, final int def)
throws QueryException {
byte[] at = element.attribute(name);
return (at == null) ? def : (int) Int.parse(at, null);
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
return (at == null) ? def : Token.toInt(at);
}
public static boolean attrib(final ANode element, final String name, final boolean def)
throws QueryException {
byte[] at = element.attribute(name);
return (at == null) ? def : (boolean) Bln.parse(at, null);
byte[] at = element.attribute(name.getBytes(StandardCharsets.UTF_8));
return (boolean) ((at == null) ? def : Bln.parse(at));
}
// e.g. TOP_LEFT
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));
}

View file

@ -1,5 +1,5 @@
<package xmlns="http://www.basex.org/modules/pkg">
<jar>thumbhelper-5.0.11.jar</jar>
<jar>thumbnailator-0.4.8.jar</jar>
<jar>thumbhelper-8.0.0.jar</jar>
<jar>thumbnailator-0.4.13.jar</jar>
<class>org.expkgzone58.image.Thumbs</class>
</package>

Binary file not shown.

Binary file not shown.

View file

@ -2,10 +2,11 @@ xquery version "3.1" encoding "UTF-8";
(:~ Generate image thumbnails using the thumbnailator library.
: @see https://github.com/coobird/thumbnailator
: @author andy bunce
: @version 0.5
: @version 0.6
:)
module namespace thumbnails = 'expkg-zone58:image.thumbnailator';
import module namespace Thumbs = "org.expkgzone58.image.Thumbs";
(:~
: generate scaled version of source image with maximum dimension of size
: @param $source base64Binary (streamed?) e.g from `fetch:binary`
@ -84,4 +85,10 @@ declare function thumbnails:validation-report($src)
as element(report)
{
validate:xsd-report($src,"task.xsd")
};
declare function thumbnails:schema-uri()
as xs:anyURI
{
resolve-uri("task.xsd")
};

View file

@ -1,8 +1,8 @@
<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>
<dependency processor="basex" />
<xquery>
<namespace>expkg-zone58:image.thumbnailator</namespace>
<file>thumbnailator.xqm</file>

View file

@ -1,18 +1,22 @@
(:~
:examples of constrain use
: generate 8 files showing all perms of aspect,fit,exif
:)
import module namespace t="expkg-zone58:image.thumbnailator";
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 $src:=file:resolve-path("resources/A34283.jpg",$file-base);
declare function local:wi($data as xs:base64Binary,$filename as xs:string)
{
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)
{
<constrain aspect="{$aspect}" fit="{$fit}" exif="{$exif}"/>
};
let $s:=function($b){if($b) then ".+" else ".-"}
let $img:= fetch:binary($src)
let $ft:=(false(),true())

37
src/test/inset.xq Normal file
View 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")

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

@ -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 $picr:=resolve-uri("resources/result2.jpg");

View file

@ -29,7 +29,7 @@ declare
};
(:~ make a thumbnail :)
(:~ validate a task :)
declare
%unit:test
function test:validate() {

View file

@ -32,7 +32,7 @@ declare %updating function write-xqdoc($path,$src,$dest){
case "application/xquery"
return file:write(
fn:resolve-uri($path || ".xml",$dest),
inspect:xqdoc($url)
inspect:xqdoc($url)
)
default
return ()