0

I can’t figure out how to get more information in one run.

For example, I would like to do some basic math for later operations (typically, scaling).

This:

import module namespace image = "http://exist-db.org/xquery/image";

let $img := util:binary-doc('/db/apps/tested-bunny/data/deepspace.jpg')
let $img-width := image:get-width($img)
let $img-height := image:get-height($img)
return
    ($img-width, $img-height)

… returns only the width.

This:

import module namespace image = "http://exist-db.org/xquery/image";

let $img := util:binary-doc('/db/apps/tested-bunny/data/deepspace.jpg')
let $img-width := image:get-width($img)
return
    ($img-width, image:get-metadata($img, true()))

… returns only the width.

This:

import module namespace image = "http://exist-db.org/xquery/image";

let $img := util:binary-doc('/db/apps/tested-bunny/data/deepspace.jpg')
return
    (image:get-width($img) * image:get-height($img))

… returns nothing.

Is the function somehow limited in getting more information at once?

Honza Hejzl
  • 874
  • 8
  • 23
  • I just tested your first example code with a jpg and a gif, and the code returned both width and height. I'm using a recent build of 3.0RC1 develop. What's your eXist version? – Joe Wicentowski Apr 20 '16 at 13:23
  • The same, 3.0.RC1. Just tested with another image, still the same. If I use one information twice, it is returned twice. If I mix them, only the first is returned. – Honza Hejzl Apr 20 '16 at 13:26
  • Whoops, If is use `util:binary-doc('/db/apps/tested-bunny/data/dev.jpg')` directly instead of the variable, it works. Really confusing. There is something really strange. – Honza Hejzl Apr 20 '16 at 13:41
  • If I use the variable more than once, it returns nothing in its second occurrence. I can use all three functions with `util:binary-doc` and it works. As soon as I want to do the same with variables, it does not work properly. – Honza Hejzl Apr 20 '16 at 13:48
  • 1
    Seems like a bug. I'd suggest trying with the latest nightly (or build from develop) to see if it's been fixed (again, I couldn't reproduce your issue on my very recent build), and if that doesn't fix it, report this as an issue with a minimal reproducible test. – Joe Wicentowski Apr 21 '16 at 11:40
  • Well, it seems in nightly build **#d084a50** it works! Thanks for the hint. I will have to wait, apparently. – Honza Hejzl Apr 21 '16 at 12:08
  • Glad to hear it works with the recent nightly. I recall seeing a commit that related to this (not specifically related to the image module, but instead related to the handling of binary-doc in similar circumstances) in the past few months, but I couldn't find it. – Joe Wicentowski Apr 21 '16 at 13:24
  • 1
    Ah, I found it: https://github.com/eXist-db/exist/commit/5ef94c1f484108077d869d8882533b358dc9c4f5?w=1. It's pretty low level, and addressed several reports. The most similar one to yours was https://github.com/eXist-db/exist/issues/492. – Joe Wicentowski Apr 21 '16 at 13:27

1 Answers1

0

As @joewiz found, this is a bug in the version 3.0.RC1 of eXist-db. In the latest nightly build it works. Solved.

Honza Hejzl
  • 874
  • 8
  • 23