Simple image manipulation (ex: thumbnailing)

1,451 views
Skip to first unread message

mpad

unread,
Mar 6, 2012, 4:36:01 AM3/6/12
to kivy-...@googlegroups.com
Hello,

I didn't find basic image manipulation routines in kivy.
We can load and display images, but what about resizing them, croping (I'd like to built a little u.i. for that), saving them ?

Do such functions exist ?
If not what would be the recommended way to do that in a Kivy app ?

Thanks !

mpad

Mathieu Virbel

unread,
Mar 6, 2012, 5:03:28 AM3/6/12
to kivy-...@googlegroups.com
Hi,

No, we don have api or methods for that in kivy. You could use another
image manipulation library like PIL or pygame.

Then after manipulation, you can create the texture manually with
Texture.create + blit_buffer.

Mathieu

mpad

unread,
Mar 7, 2012, 4:09:50 PM3/7/12
to kivy-...@googlegroups.com
Hello Mathieu,

Thanks. One more question what is the most portable/lightweight library ?
Is there any preference if I want to build a kivy app running on Linux,windows, android and MacOS (and iOS !) ?

Cheers,

mpad

Mathieu Virbel

unread,
Mar 7, 2012, 4:46:45 PM3/7/12
to kivy-...@googlegroups.com
PIL. Easy to compile, good python class :)

mpad

unread,
Mar 18, 2012, 4:27:00 PM3/18/12
to kivy-...@googlegroups.com
Hi,

Just to say I've followed your suggestion.
Indeed, that was relatively easy : I could quickly write a mini image editor widget, so thanks again !

And in case it interests anyone, I attach it here.
It is able to crop, rotate, scale the image and save the result exactly as is displayed on screen...
(should be directly executable)

mpad
miniImageEditor.py

JetK

unread,
May 27, 2014, 8:29:45 AM5/27/14
to kivy-...@googlegroups.com
That's awesome! Thanks mpad :) But, does anyone know why if one rotates the image (when it's zoomed in more than 100%) and saves it it looks like theres no antialising? With no rotation, you can zoom as much as you'd like and still get pleasant edges.

JetK

unread,
May 27, 2014, 8:55:19 AM5/27/14
to kivy-...@googlegroups.com
Ok, nevermind. I figured it out:

im=im.rotate( scatter.rotation, resample=Image.BICUBIC)

Sadly, Image.ANTIALISING does not work... But BICUBIC seems to be perfect. Looks like it does in Kivy :) Also there's an option to expand the pixels around the image, in case you rotate and leave empty space around the image. It won't cut away some of those pixels (corners?):

im=im.rotate( scatter.rotation, resample=Image.BICUBIC, expand=True)

Thanks again mpad!!! And since it's my first time posting, I'd like to give thanks to the Kivy developers for the incredible library they've made available to us!!!!! :) :)

Preethi Chandran

unread,
Oct 7, 2017, 2:37:52 AM10/7/17
to Kivy users support
i tried this.. I cant able to select photo for editing..how to do that

werton

unread,
Oct 7, 2017, 1:03:10 PM10/7/17
to Kivy users support
this editor seems to be is super minimalistic, so likely only like this
cw = ImageEditor(img_src= "photo.jpeg" )
well, or, add a file chooser dialog by youself

суббота, 7 октября 2017 г., 15:37:52 UTC+9 пользователь Preethi Chandran написал:

ayush...@cognitivemachines.co.in

unread,
Mar 14, 2019, 5:22:02 AM3/14/19
to Kivy users support
Hey Mpad,

could you please share .py file again, the one attached here seems corrupted and does not dispaly any code.
Thanks

Reply all
Reply to author
Forward
0 new messages