This commit is contained in:
Andy Bunce 2017-04-30 10:39:12 +01:00
parent f2bd581fe4
commit d25d32798a
40 changed files with 475 additions and 84 deletions

BIN
doc/constrain/A17057.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

View file

@ -0,0 +1,29 @@
(:~
:examples of constrain use
:)
import module namespace t="expkg-zone58:image.thumbnailator";
declare variable $file-base:=file:parent(static-base-uri());
declare variable $src:=file:resolve-path("A17057.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)
{
<thumbnail>
<size width="60" height="200"/>
<constrain aspect="{$aspect}" fit="{$fit}" exif="{$exif}"/>
</thumbnail>
};
let $s:=function($b){if($b) then ".+" else ".-"}
let $img:= fetch:binary($src)
let $ft:=(false(),true())
for $fit in $ft,$aspect in $ft,$exif in $ft
let $file:=("out.",
$s($aspect) , "aspect",
$s($fit), "fit",
$s($exif), "exif",
".jpg")=>string-join("")
let $task:=local:constrain($aspect,$fit,$exif)
return t:task($img,$task) => local:wi($file)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB