emesene / emesene

emesene is an instant messenger capable of connecting to various networks and utilizing different graphical toolkits. Currently msn and jabber are supported through papyon and xmppy, which allows emesene to connect to various IM services such as Windows Live Messenger, GTalk, Facebook Chat, etc.
http://www.emesene.org
Other
318 stars 160 forks source link

ability to resize pics before inserting in cache #93

Closed c10ud closed 12 years ago

c10ud commented 13 years ago

so we don't save 3000x4000 big custom emoticons...

c10ud commented 13 years ago

note: use insert_raw in Dialog.py @ class EmotesWindow(gtk.Window) after resizing, etc, omg, bbq

c10ud commented 13 years ago

gtk can resize quite every image format, but how about animated gifs? shall we write a separate module that uses imagemagick or smth? shall we save full-sizes for this type of gifs and resize at runtime? (like emesene1 does)

comment, or code

c10ud commented 13 years ago

or gtfo

GVisconti84 commented 13 years ago

It would be probably better to save them resized, if possible (and if we could easily use a third party library... without the need for writing tons of code!) so resizing is done only once, and less storage is used

c10ud commented 13 years ago

yep, problem is we don't want to depend on yet-another library (read: PIL). Maybe a resizer module in base/ that checks if it can use imagemagick/pil/whatever/nothing could be a good idea: you get the resizing if you got something, you get 3000x5000 if you don't have any of those.

Malabarba commented 13 years ago

imagemagick/pil/whatever could than be listed as recommended packages, instead of dependencies.

c10ud commented 13 years ago

maybe maybe we don't need this: actual widgets (buttons, adiumout, etc) handle well every-size emoticons. as for avatars, we have our nice resizer. i am marking this bug for 2.1, yeah

arielj commented 13 years ago

I think we can't do this without an external library or toolkit dependant code (it would be REALLY hard, a lot of compression, mathematical functions and weird things depending on the file type...), unless webkit can be used to save the resized images.

If we can't use Webkit for that, we should depend on every gui to take care of the resizing thing (I think we can't resize animated gifs though...)

We still need to resize images, sending a 3Mb file showed in 16x16px to our contacts is not nice :P

c10ud commented 13 years ago

well, i thought multiple times about this, i think the best option is having PIL as an optional dep: if it's available, you'll get the auto-resizing, otherwise it will stay as it is now.. the usual try...except thing in the import with the relevant code. it's just i'm too lazy to learn how to do this with PIL :D

arielj commented 12 years ago

It looks like PIL is not nice for resizing animated gifs, it's hard and the file could end up heavier than the original :S

I'll try with Imagemagick... maybe it likes animated gifs...

c10ud commented 12 years ago

well, imagemagick is the perfect tool, i guess a nice module that wraps command line stuff will do the trick!

c10ud commented 12 years ago

convert -resize 50x50 biggif.gif smallgif.gif

easy as that

mogrify -resize 50x50 biggif.gif

does exactly the same but overwrites the original file in place

Sbte commented 12 years ago

subprocess.call('mogrify -resize 50x50 biggif.gif', shell=True)

and we're closing the issue that has been open for the longest time? Nice :P

arielj commented 12 years ago

maybe it's better to use some wrapper around PythonMagick (subprocesses looks ugly), if there's no PythonMagick then the subprocess for resizing gif or a toolkit dependant method for non animated images if there's no ImageMagick or PIL

c10ud commented 12 years ago

gtk doesn't resize gifs (as of gtk2) as for imagemagick, chances that people (will to) install pythonmagick are very low i think, while convert/mogrify could be already installed for some reason.. PIL..i discarded it because you told it was not so good (?)

2011/8/11 arielj reply@reply.github.com:

maybe it's better to use some wrapper around PythonMagick (subprocesses looks ugly), if there's no PythonMagick then the subprocess for resizing gif or a toolkit dependant method for non animated images if there's no ImageMagick or PIL

Reply to this email directly or view it on GitHub: https://github.com/emesene/emesene/issues/93#issuecomment-1778487

arielj commented 12 years ago

I was thinking... we should stick with the toolkit resizing (it will work crossplatform without problems) and include a fallback on the core for animated gifs using imagemagick if available

and that's it! (?)

arielj commented 12 years ago

I've implemented this for gtk, can someone do it for qt?

Now, it loads the image, if it's not an animation, it's resized using gtk.gdkPixbuf method on a temp file, if it's an animation it calls Cache.resize_animated_gif that checks if convert is installed, if not, throws a warning on the logs and leave the image with the original size.

Images are not resized if their size is less than the selected size (16x16 or 50x50).

Please test it and implement this on qt, so we can finally close this.

should we do the same for avatars? I think the msn servers resizes them anyway.

EDIT: I see that custom emoticons are not supported on qt frontend yet, test with some weird images or formats using gtk so we can close this :P

c10ud commented 12 years ago

we should resize also incoming custom emoticons IMO -- people like to send you 5000x5000 pics

c10ud commented 12 years ago

but we save them with insert_raw directly from papylib (talking of papylib ofc)

c10ud commented 12 years ago

i guess we can close this (!) only minor code issues remaining!