Phatch, software de procesamiento de imágenes por lotes

El software Phatch para Linux es un potente programa que permite la modificación masiva de todo tipo de imágenes. Lo podéis utilizar para reducir, ampliar, modificar resoluciones, cambiar colores, saturación, añadir efectos, marcos o cambiar los nombres a una serie de imágenes de forma automatizada. Básicamente, consiste en indicarle los procesos en un listado y el programa se encargará de irlos ejecutando para cada foto, ahorrando gran cantidad de tiempo.

En la última versión de Phatch para Ubuntu 16.04 Xenial parece contener un error que impide la carga del programa, apareciendo el logotipo en el centro de la pantalla pero no continuando con la carga.

Si lanzas desde la línea de comandos tienes la opción de comprobar la ejecución del programa, permitiéndote identificar el error:


/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py:8196:
GtkWarning: gtk_disable_setlocale() must be called before gtk_init()
return _core_.PyApp__BootstrapApp(*args, **kwargs)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py",
line 16765, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "/usr/share/phatch/phatch/pyWx/gui.py", line 1218, in
show_frame
frame = Frame(self.filename, None, -1, ct.TITLE)
File "/usr/share/phatch/phatch/pyWx/gui.py", line 327, in __init__
frame.Frame.__init__(self, *args, **keyw)
File "/usr/share/phatch/phatch/pyWx/wxGlade/frame.py", line 141, in
__init__
self.tree = Tree(self, -1,
style=wx.TR_HAS_BUTTONS|wx.TR_NO_LINES|wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_HIDE_ROOT|wx.TR_DEFAULT_STYLE|wx.SUNKEN_BORDER)
File "/usr/share/phatch/phatch/pyWx/wxGlade/frame.py", line 26, in
__init__
set_dirty = parent.set_dirty,
File "/usr/share/phatch/phatch/lib/pyWx/treeEdit.py", line 96, in
__init__
self.CreateImageList(icon_size)
File "/usr/share/phatch/phatch/lib/pyWx/treeEdit.py", line 111, in
CreateImageList
self._AddFormToImageList(form, icon_size, icon_disabled)
File "/usr/share/phatch/phatch/lib/pyWx/treeEdit.py", line 120, in
_AddFormToImageList
wx_image = pil_wxImage(wxImage_pil(wx_image).resize(icon_size,\
File "/usr/share/phatch/phatch/lib/pyWx/wxPil.py", line 46, in
wxImage_pil
image.fromstring(wx_image.GetData())
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 737, in
fromstring "Please call frombytes() instead.") Exception: fromstring()
has been removed. Please call frombytes() instead.

Solución

Para solucionar el fallo y continuar con la carga, tendréis que modificar el archivo “usr/share/phatch/phatch/lib/pyWx/wxPil.py” y sustituir todos los “fromstring” y “tostring” por “frombytes” y “tobytes” respectivamente, quedando el archivo de este modo:

# Copyright (C) 2007-2009 www.stani.be
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>

# Follows PEP8

import Image
import wx


def pil_wxImage(image):
    if image.mode == 'P':
        image = image.convert('RGBA')
    if image.mode == 'RGBA':
        wx_image = wx.EmptyImage(*image.size)
        wx_image.SetData(image.convert("RGB").tobytes())
        wx_image.InitAlpha()
        wx_image.SetAlphaData(
            image.convert("RGBA").split()[-1].tobytes())
    else:
        wx_image = wx.EmptyImage(*image.size)
        new_image = image.convert('RGB')
        data = new_image.tobytes()
        wx_image.SetData(data)
    return wx_image


def pil_wxBitmap(image):
    return wx.BitmapFromImage(pil_wxImage(image))


def wxImage_pil(wx_image):
    size = wx_image.GetSize()
    image = Image.new('RGB', size)
    image.frombytes(wx_image.GetData())
    if wx_image.HasAlpha():
        alpha = Image.new('L', size)
        wx_alpha = wx_image.GetAlphaData()
        alpha.frombytes(wx_alpha)
        image = image.convert('RGBA')
        image.putalpha(alpha)
    return image


def wxBitmap_pil(wx_bitmap):
    return wxImage_pil(wx.ImageFromBitmap(wx_bitmap))</pre>

Este artículo es Creative Commons. Podéis copiar y compartir con mención del origen.

Referencias:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811184#12