0

We have been using AppEngine's images API with no problem for the past year. Suddenly in the last week or so the images API seems to be corrupting the image. We use the images API to do a few different operations but the one that seems to be causing the problem is that we do an images.rotation(0) on TIFF data to convert it to a PNG. (We haven't tried other file type conversions but the point is that this was working for over a year so why should it suddenly stop working? Furthermore, we need it to work with TIFF to PNG as TIFF is the format of inbound data)

This worked without problem for a long time and suddenly today I find that any TIFF that goes through the process is corrupted on output. It looks as though it's doubled and skewed.

This is using the Python 2.7 API on AppEngine 1.7.7. We are using the Google images API directly not through PIL.

Please help! This is killing our production environment.

Example code:

from google.appengine.api import images
import webapp2

def get_sample():
    # sample.tiff is a 1bit black and white group3 tiff from a fax service
    with open("sample.tiff") as x: 
        f = x.read()
    return f

class MainHandler(webapp2.RequestHandler):
    def get(self):
        # Convert to PNG using AppEngine's images API by doing a rotation of 0 degrees.
        # This worked fine for over a year and now suddenly started corrupting the 
        # output image with a grainy double image that looks like two of the 
        # same image are layered on top of each other and vibrating.
        sample = get_sample()
        png = images.rotate(sample, 0)

        self.response.headers["Content-Type"] = "image/png"
        self.response.out.write(png)

application = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
Joel
  • 3
  • 2
  • could you post some code - ie saving/retrieving images? –  May 06 '13 at 19:45
  • pardon me for sounding obvious, but since situation is critical I will say it, have you recently upgraded the AppEngine version? If so try going back to the pervious working one till you are able to figure this one out? – skywalker May 06 '13 at 21:28
  • @peterretief code example added for you. – Joel May 06 '13 at 22:47
  • @skywalker I haven't updated the api version, furthermore it's corrupting inside of the appengine images service, it doesn't matter what version i'm using. :( – Joel May 06 '13 at 22:47
  • We are working on this issue and a fix should be rolled out soon. Sorry for the inconvenience. – Sebastian Kreft May 08 '13 at 18:50
  • This should be fixed now. – Sebastian Kreft May 08 '13 at 20:22
  • @SebastianKreft - thanks, it's now fixed. Could you please explain what happened and what steps were taken to prevent it from happening again? I need to explain it to others. – Joel May 08 '13 at 22:49

3 Answers3

1

This turned out to be due to a recent change to the images API that introduced a bug which affected operations involving TIFF files, which has since been reverted. More information is in the original bug report.

https://code.google.com/p/googleappengine/issues/detail?id=9284

Andrew J
  • 1,951
  • 1
  • 14
  • 16
0

reading from here

degrees The amount to rotate the image, as a number of degrees, in multiples of 90 degrees. Must be an int or long.

can you please try

png = images.rotate(sample, 360)

and if this doesn't work try (basically rotating twice 180 degrees each so the original frame is cleared)

png1 = images.rotate(sample, 180)
png = images.rotate(png1, 180)

Hope it helps

skywalker
  • 415
  • 3
  • 9
  • no effect. I tried both the 360 suggestion and the 180 twice. I even tried the images.im_feeling_lucky() function - no luck. I have narrowed the problem down to the fact that the source image is a group3 tiff. This problem doesn't happen if the source image is any other file type. However, that doesn't help me since my source images are always going to be group3 tiffs since they come from a faxing service. What's really upsetting is that this something that worked fine for over a year and suddenly stopped working without any warning. :( – Joel May 06 '13 at 23:37
  • you might want to try by setting the output to JPEG, instead of PNG. also you can try deploying your code to a new instance (shutdown all instances running currently), just for testing. Another guess could be just test it with some images you received when it was working fine, may be something might have changed at the image source level too. I am not an expert in python, but adding try/catch might get some more information in either case, you should open a bug with app engine. Meanwhile there must be other options to convert tiff into png in python, you can use them for immediate solution. – skywalker May 07 '13 at 00:06
  • Try: Output image type JPG - no effect. Try: Shutdown all instances - no effect. Try: Test w/ old source image from before problem - no effect. Try: Contact Google w/ support ticket to report a bug - How? I have looked everywhere! I even requested Google's Silver Cloud support but they said they would get back to me before I could even sign up. Other python options to convert a tiff to a png that run on appengine? I can't find any. PIL doesn't work with group3 tiff :( – Joel May 07 '13 at 00:08
  • you can search existing issues and file a new issue [here](https://code.google.com/p/googleappengine/issues/list?can=2&q=Type%3DDefect+&colspec=ID+Type+Component+Status+Stars+Summary+Language+Priority+Owner+Log&cells=tiles) – skywalker May 07 '13 at 00:33
0

I have been using this to load the image, I don't use tiff images but that could be the problem i guess - maybe use PIL to convert the image?

class Image(BaseHandler):
    def get(self):
        employee = clockin.Employee.get(self.request.get("img_id"))
        if employee.avatar:
            self.response.headers['Content-Type'] = "image/png"
            image = images.resize(employee.avatar, 150, 150)
            self.response.out.write(image)
        else:
            self.response.out.write("No image")
  • Thanks, but the problem is the group3 compressed tiff image. It used to work fine and suddenly Google's images service stopped working correctly and started corrupting the image. – Joel May 07 '13 at 14:57