1
'''This module contains the abstract class "PictureHandler", intended to save
3
# -*- coding: utf-8 -*-
5
# This file is part of emesene.
7
# emesene is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
12
# emesene is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with emesene; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
class PictureHandler (object):
25
'''PictureHandler is an object that provides means to scale pictures and
26
save them to disk. It must be subclassed overriding abstract methods with
27
the actual save / scale routines.'''
29
# This could be useful for issue #93:
30
# We could check here for imagemagick or whatever
32
def __init__(self, source_filename=None):
34
self._source_filename = source_filename
37
def resize(self, new_size):
38
'''Resizes to new_size the given avatar pix'''
40
self._resize(new_size)
43
def _resize(self, new_size):
44
'''This method actually resizes to new_size the given avatar pix'''
45
raise NotImplementedError("Method not implemented")
48
def save(self, dest_filename):
49
'''Saves to disk the given avatar pix'''
50
if not self.can_handle():
51
shutil.copy(self._source_filename, dest_filename)
53
self._save(dest_filename)
56
def _save(self, dest_filename):
57
'''This method actually saves the pixmap to disk'''
58
raise NotImplementedError("Method not implemented")
62
'''Return true if this object is operating on an animated image'''
63
raise NotImplementedError("Method not implemented")
67
def from_toolkit(pix):
68
'''Builds a PictureHandler object from a pix object, whose type
69
depends on the particular gui toolkit used.'''
70
raise NotImplementedError("Method not implemented")