Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Crop ui.Image
-
Is there a away to crop ui.Image ? I need to avoid converting to PIL image and back to ui.Image.
Thanks.
-
take a look at this thread and see if this is your issue.
other than that... without using PIL all i could find was inside
photos
module.. make sure if you test this example you have a JPEG in your current directory calledtemp.jpg
...import ui import photos img=photos.create_image_asset('./temp.jpg').get_ui_image(size=(512,512), crop=True) v=ui.View(frame=(0, 0, 600, 800)) iv=ui.ImageView(image=img) v.add_subview(iv) v.present('sheets')
hope this helps.
-
@pavlinb try
ui_image = ui.Image.named('test:Lenna') ui_image.show() w,h = ui_image.size wc,hc = w/2,2*h/3 with ui.ImageContext(wc,hc) as ctx: ui_image.draw(-60,-20,w,h) ui_image = ctx.get_image() ui_image.show()
-
@cvp said:
@pavlinb try
ui_image = ui.Image.named('test:Lenna') ui_image.show() w,h = ui_image.size wc,hc = w/2,2*h/3 with ui.ImageContext(wc,hc) as ctx: ui_image.draw(-60,-20,w,h) ui_image = ctx.get_image() ui_image.show()
aweome! i figured
ImageContext
was the one but couldnt think of how to position croping -
@cvp It seems that your example helps a lot.
Thanks.