Skip to main content
Solved

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

  • July 12, 2021
  • 2 replies
  • 59 views

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?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • 8392 replies
  • Best Answer
  • July 13, 2021

Why not simply use the RasterResampler transformer?


bgeorges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • 21 replies
  • July 13, 2021

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