Skip to main content
Solved

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


bgeorges
Contributor
Forum|alt.badge.img+5

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>

 

 

 

Best answer by david_r

Why not simply use the RasterResampler transformer?

View original
Did this help you find an answer to your question?

2 replies

david_r
Celebrity
  • Best Answer
  • July 13, 2021

Why not simply use the RasterResampler transformer?


bgeorges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 13, 2021
david_r wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings