1

Originally, I had a table in SQL Server with a field that contained an URL to a picture.

I created an XSL template to customize the info window of that table in ArcMap. To show that image I only had to do this:

<xsl:variable name="pic" select="$theField[FieldName='PIC']/FieldValue"/>
<img border="0" src="{$pic}" width="200"/>

Now, the picture is stored as a blob in the database. A VARBINARY field.

How can I set the <img> tag from a blob source?

I've been reading several answers for similar issues here and here, but they don't fit my case or I'm being incapable of doing it.

Is even possible to accomplish it with just an XSL template?

I have already tried this (and similar variations):

<fo:instream-foreign-object content-type="image/png">
    <xsl:variable name="pic" select="$theField[FieldName='PIC']/FieldValue"/>
    <img border="0" src="{$pic}" width="200"/>
</fo:instream-foreign-object>
O.D.
  • 57
  • 9

1 Answers1

1

If the image is in a format that FOP supports (likely) and you can convert the image to Base64 (?) and FOP can use the data: scheme to inline the image data in the src property value (I can't find anything to say that it can or cannot) then you would be able to do something like:

<fo:external-graphic
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAB
3RJTUUH1AIFCDIuN9BfzQAAAAlw ... ="/>

Otherwise, you may have to come up with a URL to put in the src property value so that FOP can access the image directly from the database.

Tony Graham
  • 7,306
  • 13
  • 20
  • Thanks! Your answer took me to the right path. After several tests, I have dropped FOP and now I use: '' – O.D. Apr 27 '18 at 07:43
  • It's good that it's working for you. What are you using now instead of FOP? – Tony Graham Apr 27 '18 at 07:51
  • FWIW, AH Formatter supports the `data:` scheme: https://www.antennahouse.com/product/ahf65/ahf-gra.html – Tony Graham Apr 27 '18 at 07:52
  • I created the first binary with FME and I thought it was Base64, but it seems it wasn't. I have enconded it to Binary64 and store it in a `VARCHAR`in the database. In my XSL template I haven't used FOP or anything similar, just the `` tag with the `src` parameter as you have posted. It's working in ArcMap, so thanks!! – O.D. Apr 27 '18 at 09:32