image drawstring() landscape orientation (or image rotation function)?

Is there a straightforward way to write text onto the image in landscape orientation? I see no parameters to Image.draw_string() that would do this out of the box.

Alternatively, is there correspondingly simple way to rotate an image (one could rotate, write text, then rotate back in order to maintain an upright display). Neither the sensor nor the image modules seem to offer rotation functions.

Thanks.

No not that I know of, the text was originally added for displaying the FPS. If you like you could submit a feature request on github for text rotation (much easier, faster to implement than the alternative)

Hi, the latest firmware build offers vertical and horizontal mirroring along with image rotation. This does exactly what you want.

# Vertical Flip - Horizontal Mirror - Transpose
#
# This example shows off how to vertically flip, horizontally mirror, or
# transpose an image. Note that:
#
# vflip=False, hmirror=False, transpose=False -> 0 degree rotation
# vflip=True,  hmirror=False, transpose=True  -> 90 degree rotation
# vflip=True,  hmirror=True,  transpose=False -> 180 degree rotation
# vflip=False, hmirror=True,  transpose=True  -> 270 degree rotation

import sensor, image, time, pyb

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

mills = pyb.millis()
counter = 0

while(True):
    clock.tick()

    img = sensor.snapshot().replace(vflip=(counter//2)%2,
                                    hmirror=(counter//4)%2,
                                    transpose=(counter//8)%2)

    if (pyb.millis() > (mills + 1000)):
        mills = pyb.millis()
        counter += 1

    print(clock.fps())

firmware.zip (920 KB)

Thanks. It isn’t a crucial feature. It’s just nice to support more a traditional landscape orientation is all. I’ll give it a shot.