GEPS008: Moved ImgManip module

svn: r19901
This commit is contained in:
Nick Hall 2012-06-23 16:27:39 +00:00
parent 010325c23b
commit 742c3d770e
9 changed files with 20 additions and 23 deletions

View File

@ -3,9 +3,6 @@
# Python files
#
#src
src/ImgManip.py
# cli
src/cli/__init__.py
src/cli/user.py
@ -214,6 +211,7 @@ src/gen/simple/_simpledoc.py
src/gen/utils/__init__.py
src/gen/utils/callback.py
src/gen/utils/callman.py
src/gen/utils/image.py
src/gen/utils/referent.py
# gui - GUI code

View File

@ -15,7 +15,6 @@ gdirdir=$(prefix)/share/gramps
gdir_PYTHON = \
const.py\
gramps.py\
ImgManip.py\
LdsUtils.py \
MacTransUtils.py\
TransUtils.py\

View File

@ -13,6 +13,7 @@ pkgpython_PYTHON = \
callman.py \
configmanager.py \
fallback.py \
image.py \
place.py \
referent.py

View File

@ -46,7 +46,7 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
import ImgManip
from gen.utils.image import resize_to_jpeg
import const
from gen.plug.docgen import BaseDoc, TextDoc, FONT_SANS_SERIF, URL_PATTERN
from libhtmlbackend import HtmlBackend, process_spaces
@ -549,7 +549,7 @@ class HtmlDoc(BaseDoc, TextDoc):
imdir = self._backend.datadirfull()
try:
ImgManip.resize_to_jpeg(name, imdir + os.sep + refname, size, size, crop=crop)
resize_to_jpeg(name, imdir + os.sep + refname, size, size, crop=crop)
except:
LOG.warn(_("Could not create jpeg version of image %(name)s") %
{'name' : name})

View File

@ -88,7 +88,7 @@ from gen.plug.docgen.fontscale import string_width
from libodfbackend import OdfBackend
import const
from gen.plug.report import utils as ReportUtils
import ImgManip
from gen.utils.image import image_size, image_dpi, image_actual_size
from gen.errors import ReportError
#-------------------------------------------------------------------------
@ -1007,7 +1007,7 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
# try to open the image. If the open fails, it probably wasn't
# a valid image (could be a PDF, or a non-image)
(x, y) = ImgManip.image_size(file_name)
(x, y) = image_size(file_name)
if (x, y) == (0, 0):
return
@ -1027,10 +1027,10 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
pos = pos.title() if pos in ['left', 'right', 'single'] else 'Row'
if crop:
dpi = ImgManip.image_dpi(file_name)
dpi = image_dpi(file_name)
if dpi:
(act_width, act_height) = ImgManip.image_actual_size(
(act_width, act_height) = image_actual_size(
x_cm, y_cm, crop[2] - crop[0], crop[3] - crop[1]
)
@ -1047,9 +1047,9 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
pos += "_" + str(crop)
else:
(act_width, act_height) = ImgManip.image_actual_size(x_cm, y_cm, x, y)
(act_width, act_height) = image_actual_size(x_cm, y_cm, x, y)
else:
(act_width, act_height) = ImgManip.image_actual_size(x_cm, y_cm, x, y)
(act_width, act_height) = image_actual_size(x_cm, y_cm, x, y)
if len(alt):
self.cntnt.write(

View File

@ -41,7 +41,7 @@ LOG = logging.getLogger(".rtfdoc")
from gen.plug.docgen import (BaseDoc, TextDoc, FONT_SERIF, PARA_ALIGN_RIGHT,
PARA_ALIGN_CENTER, PARA_ALIGN_JUSTIFY,
URL_PATTERN)
import ImgManip
from gen.utils.image import image_size, image_actual_size, resize_to_jpeg_buffer
from gen.errors import ReportError
import Utils
@ -395,18 +395,18 @@ class RTFDoc(BaseDoc,TextDoc):
#--------------------------------------------------------------------
def add_media_object(self, name, pos, x_cm, y_cm, alt='', style_name=None, crop=None):
nx, ny = ImgManip.image_size(name)
nx, ny = image_size(name)
if (nx, ny) == (0,0):
return
(act_width, act_height) = ImgManip.image_actual_size(x_cm, y_cm, nx, ny)
(act_width, act_height) = image_actual_size(x_cm, y_cm, nx, ny)
act_width = twips(act_width)
act_height = twips(act_height)
size = [act_width, act_height]
buf = ImgManip.resize_to_jpeg_buffer(name, size, crop=crop)
buf = resize_to_jpeg_buffer(name, size, crop=crop)
act_width = size[0] # In case it changed because of cropping or keeping the ratio
act_height = size[1]

View File

@ -49,7 +49,7 @@ from gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, ParagraphStyle,
from gen.plug.report import utils as ReportUtils
from gen.errors import PluginError
from gen.plug.docbackend import CairoBackend
import ImgManip
from gen.utils.image import resize_to_buffer
#------------------------------------------------------------------------
#
@ -1016,9 +1016,8 @@ class GtkDocPicture(GtkDocBaseElement):
l_margin = 0
# load the image and get its extents
pixbuf = ImgManip.resize_to_buffer(self._filename,
[img_width, img_height],
self._crop)
pixbuf = resize_to_buffer(self._filename, [img_width, img_height],
self._crop)
pixbuf_width = pixbuf.get_width()
pixbuf_height = pixbuf.get_height()

View File

@ -92,7 +92,7 @@ import Utils
from gen.utils.referent import get_source_and_citation_referents
from gen.constfunc import win
from gui.thumbnails import get_thumbnail_path, run_thumbnailer
import ImgManip
from gen.utils.image import image_size, resize_to_jpeg_buffer
import gen.mime
from gen.display.name import displayer as _nd
from gen.datehandler import displayer as _dd
@ -3942,7 +3942,7 @@ class MediaPage(BasePage):
# have to await a large download unnecessarily. Either way, set
# the display image size as requested.
orig_image_path = Utils.media_path_full(self.dbase_, media.get_path())
(width, height) = ImgManip.image_size(orig_image_path)
(width, height) = image_size(orig_image_path)
max_width = self.report.options['maxinitialimagewidth']
max_height = self.report.options['maxinitialimageheight']
if width != 0 and height != 0:
@ -3960,7 +3960,7 @@ class MediaPage(BasePage):
# scale factor is significant enough to warrant making a smaller image
initial_image_path = '%s_init.jpg' % os.path.splitext(newpath)[0]
size = [new_width, new_height]
initial_image_data = ImgManip.resize_to_jpeg_buffer(orig_image_path, size)
initial_image_data = resize_to_jpeg_buffer(orig_image_path, size)
new_width = size[0] # In case it changed because of keeping the ratio
new_height = size[1]
if self.report.archive: