Solved

How to resize geodatabase image attachment using pythonCaller (Python 3.7)

  • 12 July 2021
  • 2 replies
  • 12 views

Badge

I would like to use the PIL module to resize an image stored in a blob (geodatabase attachment table) but I cannot create the Image object from the string representation in the pythonCaller

 

This is what I have tried so far:

import fme, fmeobjects
from PIL import Image
from io import StringIO
 
def processFeature(feature):
  string_io = StringIO(feature.getAttribute("data"))
  img = Image.open(string_io) #here I have the following error: Python Exception <OSError>: cannot identify image file <_io.StringIO object at 0x0000000007CE4438>
 
  img = img.resize((1000, int(round((width / float(img.size[0])) * img.size[1]))), Image.ANTIALIAS)

 

I have the following error Python Exception <OSError>: cannot identify image file <_io.StringIO object at 0x0000000007CE4438>

 

 

 

icon

Best answer by david_r 13 July 2021, 09:09

View original

2 replies

Userlevel 4

Why not simply use the RasterResampler transformer?

Badge

Why not simply use the RasterResampler transformer?

Thank you for your suggestion David!

I found out I needed to use the RasterReplacer first to get the raster from the blob field and finally the RasterExtractor to put it back into it.

fme_raster

Reply