From 742c3d770e0a95a53937023d97a8b7531c068a46 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 23 Jun 2012 16:27:39 +0000 Subject: [PATCH] GEPS008: Moved ImgManip module svn: r19901 --- po/POTFILES.skip | 4 +--- src/Makefile.am | 1 - src/gen/utils/Makefile.am | 1 + src/{ImgManip.py => gen/utils/image.py} | 0 src/plugins/docgen/htmldoc.py | 4 ++-- src/plugins/docgen/odfdoc.py | 12 ++++++------ src/plugins/docgen/rtfdoc.py | 8 ++++---- src/plugins/lib/libcairodoc.py | 7 +++---- src/plugins/webreport/narrativeweb.py | 6 +++--- 9 files changed, 20 insertions(+), 23 deletions(-) rename src/{ImgManip.py => gen/utils/image.py} (100%) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 41696d6be..cf677cd6a 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 91c4615cc..d0463a8c3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,6 @@ gdirdir=$(prefix)/share/gramps gdir_PYTHON = \ const.py\ gramps.py\ - ImgManip.py\ LdsUtils.py \ MacTransUtils.py\ TransUtils.py\ diff --git a/src/gen/utils/Makefile.am b/src/gen/utils/Makefile.am index 0c02a176e..2368247c8 100644 --- a/src/gen/utils/Makefile.am +++ b/src/gen/utils/Makefile.am @@ -13,6 +13,7 @@ pkgpython_PYTHON = \ callman.py \ configmanager.py \ fallback.py \ + image.py \ place.py \ referent.py diff --git a/src/ImgManip.py b/src/gen/utils/image.py similarity index 100% rename from src/ImgManip.py rename to src/gen/utils/image.py diff --git a/src/plugins/docgen/htmldoc.py b/src/plugins/docgen/htmldoc.py index 978f42f26..c900eda07 100644 --- a/src/plugins/docgen/htmldoc.py +++ b/src/plugins/docgen/htmldoc.py @@ -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}) diff --git a/src/plugins/docgen/odfdoc.py b/src/plugins/docgen/odfdoc.py index c4c12be7e..f25ae2664 100644 --- a/src/plugins/docgen/odfdoc.py +++ b/src/plugins/docgen/odfdoc.py @@ -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( diff --git a/src/plugins/docgen/rtfdoc.py b/src/plugins/docgen/rtfdoc.py index 729395834..ac1f2d910 100644 --- a/src/plugins/docgen/rtfdoc.py +++ b/src/plugins/docgen/rtfdoc.py @@ -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] diff --git a/src/plugins/lib/libcairodoc.py b/src/plugins/lib/libcairodoc.py index 8b121451e..fe6c2935e 100644 --- a/src/plugins/lib/libcairodoc.py +++ b/src/plugins/lib/libcairodoc.py @@ -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() diff --git a/src/plugins/webreport/narrativeweb.py b/src/plugins/webreport/narrativeweb.py index 5a94547aa..f6a10d124 100644 --- a/src/plugins/webreport/narrativeweb.py +++ b/src/plugins/webreport/narrativeweb.py @@ -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: