v5
BIN
doc/constrain/A17057.jpg
Normal file
|
After Width: | Height: | Size: 266 KiB |
29
doc/constrain/constrain.xq
Normal 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)
|
||||
BIN
doc/constrain/out..+aspect.+fit.+exif.jpg
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
doc/constrain/out..+aspect.+fit.-exif.jpg
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
doc/constrain/out..+aspect.-fit.+exif.jpg
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
doc/constrain/out..+aspect.-fit.-exif.jpg
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
doc/constrain/out..-aspect.+fit.+exif.jpg
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/constrain/out..-aspect.+fit.-exif.jpg
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/constrain/out..-aspect.-fit.+exif.jpg
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/constrain/out..-aspect.-fit.-exif.jpg
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
doc/filters-schema.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
32
doc/readme.md
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# expkg-zone58:image.thumbnailator
|
||||
|
||||
The schema is [task.xsd](../src/main/content/task.xsd)
|
||||
|
||||
## thumbnail node
|
||||
|
||||

|
||||
|
||||
Either `size` or `scale` must be specified. Everything else is optional
|
||||
|
||||
`output` can be used to change the output image format.
|
||||
|
||||
```
|
||||
<output format="gif"/>
|
||||
```
|
||||
|
||||
## Filters
|
||||
|
||||

|
||||
|
||||
## Exif
|
||||
Image handling is effected by the presence of the
|
||||
[exif-orientation](http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/) tag.
|
||||
In particular:
|
||||
* `size` and `fit` are changed
|
||||
* the `flip` filter is ignored
|
||||
|
||||
To prevent this set constrain @exif=false
|
||||
|
||||
```
|
||||
<constrain exif="false"/>
|
||||
```
|
||||
BIN
doc/thumbnail-schema.png
Normal file
|
After Width: | Height: | Size: 32 KiB |