Forum Archive

Choose format or quality for "Save Canvas"?

urbanape

Would it be possible in the future to allow us to choose a format (JPEG or PNG) or at least to specify the quality of the saved image? I'm seeing JPEG compression artifacts in some of the artwork I'm generating from Pythonista.

ccc

See Brumm's PhotoText.py... He does:

clipboard.set_image(background, format='jpeg', jpeg_quality=0.98)
photos.save_image(clipboard.get_image())

urbanape

Sorry, I should have specified that I'm working with the canvas library, which doesn't seem to have any affordances for getting the current canvas as an image to work with.

ccc

There is an undocumented console.save_raw_image_data() function that takes 5 arguments:

>>> import console
>>> dir(console)
"""['__doc__', '__name__', '__package__', 'alert', 'clear', 'hide_activity',
    'hide_output', 'hud_alert', 'input_alert', 'login_alert', 'password_alert',
    'quicklook', 'save_raw_image_data', 'secure_input', 'set_color',
    'set_font', 'show_activity', 'show_image', 'write_link']"""
>>> console.save_raw_image_data()
"""Traceback (most recent call last):
      File "<string>", line 1, in <module>
    TypeError: function takes exactly 5 arguments (0 given)"""
kw

From Image.Py

console.save_raw_image_data(image_data, 'RGBA', image_to_save.size[0], image_to_save.size[1], filename)
urbanape

Hmm, wondering if we can get the raw image data from canvas in the future.