Re: [xsl] Image size with XSL?

Subject: Re: [xsl] Image size with XSL?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 18 Dec 2016 20:02:51 -0000
On Sun, Dec 18, 2016 at 07:54:10PM -0000, Mark Wilson mark@xxxxxxxxxxxx scripsit:
[snip]
> I would like to add the placement-index to the XML data source
> programmatically. Is there a way to obtain the height or width of a jpeg
> image from the file itself (image.jpg, for instance) using XSLT? Or, can
> someone suggest another way to do this programmatically?

You can't do that directly with XSLT. (Well... Turing-complete
programming language.  You can't do that easily and absent considerable
suffering with XSLT.)  The usual way is to use something
like http://www.graphicsmagick.org/ and a scripting language to extract
the information you want and to stick it in meta-data XML files
associated with the image.  (So you'd have image.jpg and
image_meta.xml.)  Then XSLT can read the image_meta.xml file to get the
necessary information.

This has problems because when you have lots of little files file-IO
tends to dominate your run time, but it's also hard to avoid, and at
least this way you have the prospect of stuffing all the imagine meta
into a single collection at the start.

-- Graydon

Current Thread