Hello community,
here is the log from the commit of package python-OpenEXR for openSUSE:Factory
checked in at Sat Aug 29 01:10:55 CEST 2009.
--------
--- python-OpenEXR/python-OpenEXR.changes 2009-06-02 08:56:06.000000000 +0200
+++ python-OpenEXR/python-OpenEXR.changes 2009-08-26 15:46:55.000000000 +0200
@@ -1,0 +2,7 @@
+Wed Aug 26 13:46:15 UTC 2009 - mvyskocil@suse.cz
+
+- Update to 1.0.3:
+ * Improvements to error messages, argument parsing, and module
+ * initialisation, thanks to Campbell Barton.
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
OpenEXR-1.0.tar.bz2
New:
----
OpenEXR-1.0.3.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-OpenEXR.spec ++++++
--- /var/tmp/diff_new_pack.Q7ll2j/_old 2009-08-29 01:09:42.000000000 +0200
+++ /var/tmp/diff_new_pack.Q7ll2j/_new 2009-08-29 01:09:42.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package python-OpenEXR (Version 1.0)
+# spec file for package python-OpenEXR (Version 1.0.3)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -19,13 +19,13 @@
Name: python-OpenEXR
-Version: 1.0
-Release: 2
+Version: 1.0.3
+Release: 1
Summary: Python bindings for OpenEXR
Group: Development/Libraries/Python
License: BSD 3-clause (or similar)
Url: http://excamera.com/articles/26/openexr.html
-Source0: http://excamera.com/files/OpenEXR-%{version}.tar.bz2
+Source0: http://pypi.python.org/packages/source/O/OpenEXR/OpenEXR-%{version}.tar.bz2
Source1: http://excamera.com/files/OpenEXR.pdf
# license will be included in future release
# see http://www.mail-archive.com/openexr-devel@nongnu.org/msg00844.html
@@ -90,6 +90,7 @@
python setup.py install \
--root=%{buildroot} \
--prefix=%{_prefix} \
+ --install-data=%{_datadir}/%{name}-%{version} \
--record-rpm=INSTALLED_FILES
%clean
@@ -97,7 +98,8 @@
%files -f INSTALLED_FILES
%defattr(-,root,root,0755)
-%doc index.rst license.txt
+%doc license.txt
+%dir %{_datadir}/%{name}-%{version}/
%files doc
%defattr(-,root,root,0755)
++++++ OpenEXR-1.0.tar.bz2 -> OpenEXR-1.0.3.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/Imath.py new/OpenEXR-1.0.3/Imath.py
--- old/OpenEXR-1.0/Imath.py 2009-05-26 02:33:41.000000000 +0200
+++ new/OpenEXR-1.0.3/Imath.py 2009-08-15 17:31:01.000000000 +0200
@@ -20,7 +20,7 @@
pass
class Box:
- """Box is a 2D box, specified by its two corners *min* and *max*."""
+ """Box is a 2D box, specified by its two corners *min* and *max*, both of which are :class:`point` """
def __init__(self, min = None, max = None):
self.min = min
self.max = max
@@ -83,6 +83,7 @@
PIZ_COMPRESSION = 4
PXR24_COMPRESSION = 5
def __init__(self, v):
+ """l"""
self.v = v
def __repr__(self):
return [ "NO_COMPRESSION", "RLE_COMPRESSION", "ZIPS_COMPRESSION", "ZIP_COMPRESSION", "PIZ_COMPRESSION", "PXR24_COMPRESSION"][self.v]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/MANIFEST new/OpenEXR-1.0.3/MANIFEST
--- old/OpenEXR-1.0/MANIFEST 2009-05-26 02:51:36.000000000 +0200
+++ new/OpenEXR-1.0.3/MANIFEST 1970-01-01 01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-Imath.py
-OpenEXR.cpp
-setup.py
-test.py
-MANIFEST
-Makefile
-conf.py
-index.rst
-intro.rst
-openexr.rst
-imath.rst
-lena.jpg
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/Makefile new/OpenEXR-1.0.3/Makefile
--- old/OpenEXR-1.0/Makefile 2009-05-25 21:12:47.000000000 +0200
+++ new/OpenEXR-1.0.3/Makefile 1970-01-01 01:00:00.000000000 +0100
@@ -1,88 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
-
-help:
- @echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make standalone HTML files"
- @echo " dirhtml to make HTML files named index.html in directories"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " qthelp to make HTML files and a qthelp project"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " changes to make an overview of all changed/added/deprecated items"
- @echo " linkcheck to check all external links for integrity"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- -rm -rf _build/*
-
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
- @echo
- @echo "Build finished. The HTML pages are in _build/html."
-
-dirhtml:
- $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
- @echo
- @echo "Build finished. The HTML pages are in _build/dirhtml."
-
-pickle:
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
- @echo
- @echo "Build finished; now you can process the pickle files."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
- @echo
- @echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in _build/htmlhelp."
-
-qthelp:
- $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp
- @echo
- @echo "Build finished; now you can run "qcollectiongenerator" with the" \
- ".qhcp project file in _build/qthelp, like this:"
- @echo "# qcollectiongenerator _build/qthelp/OpenEXR.qhcp"
- @echo "To view the help file:"
- @echo "# assistant -collectionFile _build/qthelp/OpenEXR.qhc"
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
- @echo
- @echo "Build finished; the LaTeX files are in _build/latex."
- @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
- "run these through (pdf)latex."
-
-changes:
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
- @echo
- @echo "The overview file is in _build/changes."
-
-linkcheck:
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
- @echo
- @echo "Link check complete; look for any errors in the above output " \
- "or in _build/linkcheck/output.txt."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in _build/doctest/output.txt."
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/OpenEXR.cpp new/OpenEXR-1.0.3/OpenEXR.cpp
--- old/OpenEXR-1.0/OpenEXR.cpp 2009-05-26 02:34:38.000000000 +0200
+++ new/OpenEXR-1.0.3/OpenEXR.cpp 2009-08-21 20:54:25.000000000 +0200
@@ -43,7 +43,7 @@
static PyObject *OpenEXR_error = NULL;
static PyObject *pModuleImath;
-static PyObject *PyObject_StealAttrString(PyObject* o, char *name)
+static PyObject *PyObject_StealAttrString(PyObject* o, const char *name)
{
PyObject *r = PyObject_GetAttrString(o, name);
Py_DECREF(r);
@@ -72,7 +72,7 @@
char *cname;
PyObject *pixel_type = NULL;
- char *keywords[] = { "channel_name", "pixel_type", "scanLine1", "scanLine2", NULL };
+ char *keywords[] = { (char*)"channel_name", (char*)"pixel_type", (char*)"scanLine1", (char*)"scanLine2", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|Oii", keywords, &cname, &pixel_type, &miny, &maxy))
return NULL;
@@ -148,6 +148,112 @@
return r;
}
+static PyObject *channels(PyObject *self, PyObject *args, PyObject *kw)
+{
+ InputFile *file = &((InputFileC *)self)->i;
+
+ Box2i dw = file->header().dataWindow();
+ int miny, maxy;
+
+ miny = dw.min.y;
+ maxy = dw.max.y;
+
+ PyObject *clist;
+ PyObject *pixel_type = NULL;
+ char *keywords[] = { (char*)"channel_name", (char*)"pixel_type", (char*)"scanLine1", (char*)"scanLine2", NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "O|Oii", keywords, &clist, &pixel_type, &miny, &maxy))
+ return NULL;
+
+ if (maxy < miny) {
+ PyErr_SetString(PyExc_TypeError, "scanLine1 must be <= scanLine2");
+ return NULL;
+ }
+ if (miny < dw.min.y) {
+ PyErr_SetString(PyExc_TypeError, "scanLine1 cannot be outside dataWindow");
+ return NULL;
+ }
+ if (maxy > dw.max.y) {
+ PyErr_SetString(PyExc_TypeError, "scanLine2 cannot be outside dataWindow");
+ return NULL;
+ }
+
+ ChannelList channels = file->header().channels();
+ FrameBuffer frameBuffer;
+
+ int width = dw.max.x - dw.min.x + 1;
+ int height = maxy - miny + 1;
+
+ PyObject *retval = PyList_New(0);
+ PyObject *iterator = PyObject_GetIter(clist);
+ if (iterator == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Channel list must be iterable");
+ return NULL;
+ }
+ PyObject *item;
+
+ while ((item = PyIter_Next(iterator)) != NULL) {
+ char *cname = PyString_AsString(item);
+ Channel *channelPtr = channels.findChannel(cname);
+ if (channelPtr == NULL) {
+ return PyErr_Format(PyExc_TypeError, "There is no channel '%s' in the image", cname);
+ }
+
+ Imf::PixelType pt;
+ if (pixel_type != NULL) {
+ pt = PixelType(PyLong_AsLong(PyObject_StealAttrString(pixel_type, "v")));
+ } else {
+ pt = channelPtr->type;
+ }
+
+ // Use pt to compute typeSize
+ size_t typeSize;
+ switch (pt) {
+ case HALF:
+ typeSize = 2;
+ break;
+
+ case FLOAT:
+ case UINT:
+ typeSize = 4;
+ break;
+
+ default:
+ PyErr_SetString(PyExc_TypeError, "Unknown type");
+ return NULL;
+ }
+
+ size_t xstride = typeSize;
+ size_t ystride = typeSize * width;
+
+ PyObject *r = PyString_FromStringAndSize(NULL, typeSize * width * height);
+ PyList_Append(retval, r);
+ Py_DECREF(r);
+
+ char *pixels = PyString_AsString(r);
+
+ try
+ {
+ frameBuffer.insert(cname,
+ Slice(pt,
+ pixels - dw.min.x * xstride - miny * ystride,
+ xstride,
+ ystride,
+ 1,1,
+ 0.0));
+ }
+ catch (const std::exception &e)
+ {
+ PyErr_SetString(PyExc_IOError, e.what());
+ return NULL;
+ }
+ Py_DECREF(item);
+ }
+ Py_DECREF(iterator);
+ file->setFrameBuffer(frameBuffer);
+ file->readPixels(miny, maxy);
+
+ return retval;
+}
static PyObject *inclose(PyObject *self, PyObject *args)
{
InputFileC *pc = ((InputFileC *)self);
@@ -187,12 +293,10 @@
PyObject *pt[2];
pt[0] = PyObject_CallObject(pPointFunc, ptargs[0]);
pt[1] = PyObject_CallObject(pPointFunc, ptargs[1]);
- PyObject *boxArgs = Py_BuildValue("OO", pt[0], pt[1]);
+ PyObject *boxArgs = Py_BuildValue("NN", pt[0], pt[1]);
ob = PyObject_CallObject(pBoxFunc, boxArgs);
Py_DECREF(boxArgs);
- Py_DECREF(pt[0]);
- Py_DECREF(pt[1]);
Py_DECREF(ptargs[0]);
Py_DECREF(ptargs[1]);
} else if (const PreviewImageAttribute *pia = dynamic_cast (a)) {
@@ -215,13 +319,12 @@
for (ChannelList::ConstIterator j = cl.begin(); j != cl.end(); ++j) {
PyObject *ptarg = Py_BuildValue("(i)", j.channel().type);
PyObject *pt = PyObject_CallObject(pPTFunc, ptarg);
- PyObject *chanarg = Py_BuildValue("Oii",
+ PyObject *chanarg = Py_BuildValue("Nii",
pt,
j.channel().xSampling,
j.channel().ySampling);
PyObject *C = PyObject_CallObject(pChanFunc, chanarg);
PyDict_SetItemString(CS, j.name(), C);
- Py_DECREF(pt);
Py_DECREF(C);
Py_DECREF(ptarg);
Py_DECREF(chanarg);
@@ -267,11 +370,19 @@
return dict_from_header(file->header());
}
+static PyObject *isComplete(PyObject *self, PyObject *args)
+{
+ InputFile *file = &((InputFileC *)self)->i;
+ return PyBool_FromLong(file->isComplete());
+}
+
/* Method table */
static PyMethodDef InputFile_methods[] = {
{"header", inheader, METH_VARARGS},
{"channel", (PyCFunction)channel, METH_KEYWORDS},
+ {"channels", (PyCFunction)channels, METH_KEYWORDS},
{"close", inclose, METH_VARARGS},
+ {"isComplete", isComplete, METH_VARARGS},
{NULL, NULL},
};
@@ -302,7 +413,7 @@
static PyTypeObject InputFile_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "InputFile",
+ "OpenEXR.InputFile",
sizeof(InputFileC),
0,
(destructor)InputFile_dealloc,
@@ -323,7 +434,7 @@
0,
- Py_TPFLAGS_CHECKTYPES,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,
0,
@@ -333,27 +444,27 @@
/* the rest are NULLs */
};
-PyObject *makeInputFile(PyObject *self, PyObject *args)
+int makeInputFile(PyObject *self, PyObject *args, PyObject *kwds)
{
- InputFileC *object;
+ InputFileC *object = ((InputFileC *)self);
char *filename;
- if (!PyArg_ParseTuple(args, "s", &filename))
- return NULL;
+ if (!PyArg_ParseTuple(args, "s:InputFile", &filename))
+ return -1;
- object = PyObject_NEW(InputFileC, &InputFile_Type);
- object->is_opened = 1;
try
{
new(&object->i) InputFile(filename);
}
catch (const std::exception &e)
{
+ // Py_DECREF(object);
PyErr_SetString(PyExc_IOError, e.what());
- return NULL;
+ return -1;
}
+ object->is_opened = 1;
- return (PyObject *)object;
+ return 0;
}
@@ -375,8 +486,9 @@
Box2i dw = file->header().dataWindow();
int width = dw.max.x - dw.min.x + 1;
int height = dw.max.y - dw.min.y + 1;
- PyObject *pixeldata = PyTuple_GetItem(args, 0);
- if (!PyArg_ParseTuple(args, "O|i", &pixeldata, &height))
+ PyObject *pixeldata;
+
+ if (!PyArg_ParseTuple(args, "O!|i:writePixels", &PyDict_Type, &pixeldata, &height))
return NULL;
FrameBuffer frameBuffer;
@@ -430,8 +542,8 @@
}
catch (const std::exception &e)
{
- PyErr_SetString(PyExc_IOError, e.what());
- return NULL;
+ PyErr_SetString(PyExc_IOError, e.what());
+ return NULL;
}
Py_RETURN_NONE;
@@ -488,7 +600,7 @@
static PyTypeObject OutputFile_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
- "OutputFile",
+ "OpenEXR.OutputFile",
sizeof(OutputFileC),
0,
(destructor)OutputFile_dealloc,
@@ -509,7 +621,7 @@
0,
- Py_TPFLAGS_CHECKTYPES,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
0,
0,
@@ -519,16 +631,15 @@
/* the rest are NULLs */
};
-PyObject *makeOutputFile(PyObject *self, PyObject *args)
+int makeOutputFile(PyObject *self, PyObject *args, PyObject *kwds)
{
char *filename;
PyObject *header_dict;
- if (!PyArg_ParseTuple(args, "sO", &filename, &header_dict))
- return NULL;
+ if (!PyArg_ParseTuple(args, "sO!:OutputFile", &filename, &PyDict_Type, &header_dict))
+ return -1;
- OutputFileC *object = PyObject_NEW(OutputFileC, &OutputFile_Type);
- object->is_opened = 1;
+ OutputFileC *object = (OutputFileC *)self;
Header header(64, 64);
@@ -611,10 +722,11 @@
}
catch (const std::exception &e)
{
- PyErr_SetString(PyExc_IOError, e.what());
- return NULL;
+ PyErr_SetString(PyExc_IOError, e.what());
+ return -1;
}
- return (PyObject *)object;
+ object->is_opened = 1;
+ return 0;
}
////////////////////////////////////////////////////////////////////////
@@ -622,7 +734,7 @@
PyObject *makeHeader(PyObject *self, PyObject *args)
{
int w, h;
- if (!PyArg_ParseTuple(args, "ii", &w, &h))
+ if (!PyArg_ParseTuple(args, "ii:Header", &w, &h))
return NULL;
Header header(w, h);
header.channels().insert("R", Channel(FLOAT));
@@ -646,7 +758,7 @@
PyObject *_isOpenExrFile(PyObject *self, PyObject *args)
{
char *filename;
- if (!PyArg_ParseTuple(args, "s", &filename))
+ if (!PyArg_ParseTuple(args, "s:isOpenExrFile", &filename))
return NULL;
return PyBool_FromLong(isOpenExrFile(filename));
}
@@ -654,34 +766,43 @@
////////////////////////////////////////////////////////////////////////
static PyMethodDef methods[] = {
- {"InputFile", makeInputFile, METH_VARARGS},
- {"OutputFile", makeOutputFile, METH_VARARGS},
- {"Header", makeHeader, METH_VARARGS},
- {"isOpenExrFile", _isOpenExrFile, METH_VARARGS},
- {NULL, NULL},
+ {"Header", makeHeader, METH_VARARGS},
+ {"isOpenExrFile", _isOpenExrFile, METH_VARARGS},
+ {NULL, NULL},
};
extern "C" void initOpenEXR()
{
- PyObject *m, *d;
+ PyObject *m, *d, *item;
Imf::staticInitialize();
m = Py_InitModule("OpenEXR", methods);
d = PyModule_GetDict(m);
- pModuleImath = PyImport_Import(PyString_FromString("Imath"));
+ pModuleImath = PyImport_Import(item= PyString_FromString("Imath")); Py_DECREF(item);
/* initialize module variables/constants */
+ InputFile_Type.tp_new = PyType_GenericNew;
+ InputFile_Type.tp_init = makeInputFile;
+ OutputFile_Type.tp_new = PyType_GenericNew;
+ OutputFile_Type.tp_init = makeOutputFile;
+ if (PyType_Ready(&InputFile_Type) != 0)
+ return;
+ if (PyType_Ready(&OutputFile_Type) != 0)
+ return;
+ PyModule_AddObject(m, "InputFile", (PyObject *)&InputFile_Type);
+ PyModule_AddObject(m, "OutputFile", (PyObject *)&OutputFile_Type);
#if PYTHON_API_VERSION >= 1007
- OpenEXR_error = PyErr_NewException("OpenEXR.error", NULL, NULL);
+ OpenEXR_error = PyErr_NewException((char*)"OpenEXR.error", NULL, NULL);
#else
- OpenEXR_error = Py_BuildValue("s", "OpenEXR.error");
+ OpenEXR_error = PyString_FromString("OpenEXR.error");
#endif
PyDict_SetItemString(d, "error", OpenEXR_error);
+ Py_DECREF(OpenEXR_error);
- PyDict_SetItemString(d, "UINT", PyLong_FromLong(UINT));
- PyDict_SetItemString(d, "HALF", PyLong_FromLong(HALF));
- PyDict_SetItemString(d, "FLOAT", PyLong_FromLong(FLOAT));
+ PyDict_SetItemString(d, "UINT", item= PyLong_FromLong(UINT)); Py_DECREF(item);
+ PyDict_SetItemString(d, "HALF", item= PyLong_FromLong(HALF)); Py_DECREF(item);
+ PyDict_SetItemString(d, "FLOAT", item= PyLong_FromLong(FLOAT)); Py_DECREF(item);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/PKG-INFO new/OpenEXR-1.0.3/PKG-INFO
--- old/OpenEXR-1.0/PKG-INFO 2009-05-26 05:33:00.000000000 +0200
+++ new/OpenEXR-1.0.3/PKG-INFO 2009-08-21 21:29:13.000000000 +0200
@@ -1,10 +1,10 @@
Metadata-Version: 1.0
Name: OpenEXR
-Version: 1.0
-Summary: UNKNOWN
+Version: 1.0.3
+Summary: Python bindings for ILM's OpenEXR image file format
Home-page: http://excamera.com/articles/26/openexr.html
Author: James Bowman
Author-email: jamesb@excamera.com
License: UNKNOWN
-Description: UNKNOWN
+Description: Python bindings for ILM's OpenEXR image file format
Platform: UNKNOWN
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/conf.py new/OpenEXR-1.0.3/conf.py
--- old/OpenEXR-1.0/conf.py 2009-05-26 00:35:31.000000000 +0200
+++ new/OpenEXR-1.0.3/conf.py 1970-01-01 01:00:00.000000000 +0100
@@ -1,194 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# OpenEXR documentation build configuration file, created by
-# sphinx-quickstart on Mon May 25 12:12:47 2009.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-import sys, os
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.append(os.path.abspath('.'))
-
-# -- General configuration -----------------------------------------------------
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.doctest', 'sphinx.ext.autodoc']
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# The suffix of source filenames.
-source_suffix = '.rst'
-
-# The encoding of source files.
-#source_encoding = 'utf-8'
-
-# The master toctree document.
-master_doc = 'index'
-
-# General information about the project.
-project = u'Python OpenEXR'
-copyright = u'2009, James Bowman'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '1.0'
-# The full version, including alpha/beta/rc tags.
-release = '1.0'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of documents that shouldn't be included in the build.
-#unused_docs = []
-
-# List of directories, relative to source directory, that shouldn't be searched
-# for source files.
-exclude_trees = ['_build']
-
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. Major themes that come with
-# Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_use_modindex = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'OpenEXRdoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
-
-# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
- ('index', 'OpenEXR.tex', u'OpenEXR Documentation',
- u'James Bowman', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_use_modindex = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/imath.rst new/OpenEXR-1.0.3/imath.rst
--- old/OpenEXR-1.0/imath.rst 2009-05-26 00:33:28.000000000 +0200
+++ new/OpenEXR-1.0.3/imath.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-.. automodule:: Imath
- :members:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/index.rst new/OpenEXR-1.0.3/index.rst
--- old/OpenEXR-1.0/index.rst 2009-05-26 02:56:28.000000000 +0200
+++ new/OpenEXR-1.0.3/index.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-========================
-Python OpenEXR |version|
-========================
-
-.. toctree::
- :maxdepth: 2
-
- intro
- openexr
- imath
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/intro.rst new/OpenEXR-1.0.3/intro.rst
--- old/OpenEXR-1.0/intro.rst 2009-05-26 02:16:36.000000000 +0200
+++ new/OpenEXR-1.0.3/intro.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,23 +0,0 @@
-Introduction
-============
-
-.. index:: ILM, Industrial Light & Magic, high dynamic range
-
-OpenEXR is an image format developed by ILM. Its main innovation is
-support for high dynamic range: it supports floating point pixels.
-
-These modules provide Python bindings for the OpenEXR libraries: it
-allows you to read and write OpenEXR files from Python.
-
-Note that this module only loads and stores images: it does not do
-any image manipulation operations. For that you might want to use
-one of:
-
-.. index:: PIL, NumPy, vop, OpenCV, HALF, UINT, FLOAT
-
-* Python's standard `array http://docs.python.org/library/array.html`_ module. You can access the raw data of FLOAT and UINT images.
-* The `Python Imaging Library http://www.pythonware.com/library/pil/handbook/index.htm`_. This library supports a single FLOAT channel image format.
-* `Numeric or NumPy http://numpy.scipy.org/`_. It's just math, so you will have to write your own imaging operations. Supports UINT and FLOAT formats.
-* Module `vop http://www.excamera.com/articles/25/vop.html`_. NumPy subset, but faster. Supports FLOAT and HALF.
-* `OpenCV http://opencv.willowgarage.com/wiki/`_. Supports multi channel UINT and FLOAT formats.
-
Files old/OpenEXR-1.0/lena.jpg and new/OpenEXR-1.0.3/lena.jpg differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/openexr.rst new/OpenEXR-1.0.3/openexr.rst
--- old/OpenEXR-1.0/openexr.rst 2009-05-26 04:11:10.000000000 +0200
+++ new/OpenEXR-1.0.3/openexr.rst 1970-01-01 01:00:00.000000000 +0100
@@ -1,247 +0,0 @@
-:mod:`OpenEXR` --- Read and write EXR format images
-===================================================
-
-.. module:: OpenEXR
- :synopsis: Read and write EXR format images
-
-Available Types
----------------
-
-.. class:: InputFile
-
- A :class:`InputFile` object is used to read an EXR file.
-
- .. doctest::
- :options: -ELLIPSIS, +NORMALIZE_WHITESPACE
-
- >>> import OpenEXR
- >>> print len(OpenEXR.InputFile("GoldenGate.exr").channel('R')), "bytes of red data"
- 2170640 bytes of red data
-
- The following data items and methods are supported:
-
- .. method:: InputFile.header()
-
- Return the header of the open file. The header is a dictionary as described below.
-
- .. index:: scanline
-
- .. method:: channel(cname[, pixel_type[, scanLine1[, scanLine2]]]) -> string
-
- Read a channel from the OpenEXR image. *cname* is the name
- of the channel in the image, for example "R".
- This method reads the
- channel data in the format specified by *pixel_type* (see
- :class:`Imath.PixelType`), or the format of the data specified in the image itself by default.
- If *scanLine1* and *scanLine2* are not supplied, then the method reads the
- entire image. Note that this method returns the channel as a
- Python string: the caller must then convert it to the appropriate
- format as necessary.
-
- .. index:: destructor
-
- .. method:: close()
-
- Close the open file. Calling this method is mandantory, otherwise
- the file will be incomplete. However, as a convenience, the
- object's destructor calls this method, so any open files are
- automatically closed at program exit.
-
-
-.. class:: OutputFile(filename, header)
-
- Creates the EXR file *filename*, with given *header*. *header*
- contains the image's properties and is a dict created by
- :func:`Header`.
-
- .. doctest::
-
- >>> import OpenEXR, array
- >>> data = array.array('f', [ 1.0 ] * (640 * 480)).tostring()
- >>> exr = OpenEXR.OutputFile("out.exr", OpenEXR.Header(640,480))
- >>> exr.writePixels({'R': data, 'G': data, 'B': data})
-
- The following data items and methods are supported:
-
- .. index:: scanline
-
- .. method:: writePixels(dict, [scanlines])
-
- Write the specified channels to the OpenEXR image. *dict*
- specifies multiple channels. If *scanlines* is not specified,
- then the entire image is assumed. dict specifies each channel's
- data as channel:data, where channel and data are both strings.
- This method uses the file's header
- to determine the format of the data (FLOAT, HALF or UINT) for
- each channel. If the string data is not of the appropriate size,
- this method raises an exception.
-
- .. method:: currentScanLine()
-
- Return the current scan line being written.
-
- .. index:: destructor
-
- .. method:: close()
-
- Close the open file. This method may be called multiple times.
- As a convenience, the object's destructor calls this method.
-
-Available Functions
--------------------
-.. function:: isOpenExrFile(filename) -> bool
-
- Returns True if the *filename* exists, is readable, and contains a valid EXR image.
-
- .. doctest::
-
- >>> import OpenEXR
- >>> print OpenEXR.isOpenExrFile("no-such-file")
- False
- >>> print OpenEXR.isOpenExrFile("lena.jpg")
- False
- >>> print OpenEXR.isOpenExrFile("GoldenGate.exr")
- True
-
-.. function:: Header(width, height) -> dict
-
- Convenience function that creates the EXR header for an image
- of size *width* x *height* with EXR mandatory entries set to
- appropriate defaults. An EXR header is a dictionary -
- see :ref:`headers` for details of legal header contents.
-
- .. doctest::
- :options: -ELLIPSIS, +NORMALIZE_WHITESPACE
-
- >>> import OpenEXR
- >>> print OpenEXR.Header(640,480)
- {'compression': ZIP_COMPRESSION,
- 'pixelAspectRatio': 1.0,
- 'displayWindow': (0, 0) - (639, 479),
- 'channels': {'R': FLOAT (1, 1), 'B': FLOAT (1, 1), 'G': FLOAT (1, 1)},
- 'dataWindow': (0, 0) - (639, 479),
- 'screenWindowCenter': (0.0, 0.0),
- 'screenWindowWidth': 1.0,
- 'lineOrder': INCREASING_Y}
-
-
-.. _headers:
-
-EXR header values
------------------
-
-.. index::
- pair: header; values
-
-This module represents EXR headers as regular Python dictionaries.
-In this dictionary the keys are strings, and the values are such
-that OpenEXR can determine their type. The module Imath provides
-many of the classes for attribute types.
-
- .. doctest::
- :options: -ELLIPSIS, +NORMALIZE_WHITESPACE
-
- >>> import OpenEXR
- >>> print OpenEXR.InputFile("GoldenGate.exr").header()
- {'tiles': None,
- 'capDate': '2004:01:04 18:10:00',
- 'compression': PIZ_COMPRESSION,
- 'latitude': 37.827701568603516,
- 'pixelAspectRatio': 1.0,
- 'altitude': 274.5,
- 'displayWindow': (0, 0) - (1261, 859),
- 'focus': inf,
- 'comments': 'View from Hawk Hill towards San Francisco',
- 'screenWindowWidth': 1.1499999761581421,
- 'channels': {'R': HALF (1, 1), 'B': HALF (1, 1), 'G': HALF (1, 1)},
- 'isoSpeed': 50.0,
- 'utcOffset': 28800.0,
- 'longitude': -122.49960327148438,
- 'dataWindow': (0, 0) - (1261, 859),
- 'screenWindowCenter': (0.0, 0.0),
- 'aperture': 2.7999999523162842,
- 'preview': ,
- 'owner': 'Copyright 2004 Industrial Light & Magic',
- 'expTime': 8.0,
- 'lineOrder': INCREASING_Y}
-
- Values in the dictionary may be:
-
-.. index::
- single: header; string
-
-string
-
- ::
-
- header['owner'] = 'Copyright 2007 James Bowman'
-
-.. index::
- single: header; float
-
-float
-
- ::
-
- header['isoSpeed'] = 50.0
-
-.. index::
- single: header; int
-
-int
-
- ::
-
- header['version'] = 1001
-
-.. index::
- single: header; dict
-
-dict
-
- A dict represents the image's channels. In the dict, the keys are the channel names, and the values are of class Imath.Channel::
-
- header['channels'] = { 'L' : Imath.Channel(PixelType(OpenEXR.HALF)),
- 'Z' : Imath.Channel(PixelType(OpenEXR.FLOAT))}
-
-:class:`Imath.Box2i`
-
- ::
-
- header['dataWindow'] = Imath.Box2i(Imath.point(0,0), Imath.point(640,480))
-
-:class:`Imath.Box2f`
-
- ::
-
- header['regionOfInterest'] = Imath.Box2f(Imath.point(75.0,75.0),
- Imath.point(100.0,100.0))
-
-
-:class:`Imath.V2f`
-
- ::
-
- header['originMarker'] = Imath.point(0.378, 0.878)
-
-:class:`Imath.LineOrder`
-
- ::
-
- header['lineOrder'] = Imath.LineOrder(Imath.LineOrder.INCREASING_Y)
-
-:class:`Imath.PreviewImage`
-
- A preview image, specified by height, width, and a string of length 4*width*height. The pixels are in RGBA order.::
-
- header['preview'] = Imath.PreviewImage(320,200,pixels)
-
- or to use a `PIL http://www.pythonware.com/products/pil/`_ image as an EXR preview::
-
- header['preview'] = Imath.PreviewImage(im.size[0], im.size[1], im.convert("RGBA").tostring())
-
-:class:`Imath.Compression`
-
- ::
-
- header['Compression'] = Imath.Compression(Imath.Compression.PIZ_COMPRESSION)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/setup.py new/OpenEXR-1.0.3/setup.py
--- old/OpenEXR-1.0/setup.py 2009-05-26 04:34:44.000000000 +0200
+++ new/OpenEXR-1.0.3/setup.py 2009-08-21 20:54:25.000000000 +0200
@@ -9,12 +9,18 @@
author = 'James Bowman',
author_email = 'jamesb@excamera.com',
url = 'http://excamera.com/articles/26/openexr.html',
- version='1.0',
+ description = "Python bindings for ILM's OpenEXR image file format",
+ long_description = "Python bindings for ILM's OpenEXR image file format",
+ version='1.0.3',
+ data_files=['test-exr.py'],
ext_modules=[
- Extension('OpenEXR',
- ['OpenEXR.cpp'],
- include_dirs=['/usr/include/OpenEXR', '/usr/local/include/OpenEXR'],
- library_dirs=['/usr/local/lib'],
- libraries=['Iex', 'Half', 'Imath', 'IlmImf', 'z'],
- extra_compile_args=['-g'])
- ], py_modules=['Imath'],)
+ Extension('OpenEXR',
+ ['OpenEXR.cpp'],
+ include_dirs=['/usr/include/OpenEXR', '/usr/local/include/OpenEXR'],
+ library_dirs=['/usr/local/lib'],
+ libraries=['Iex', 'Half', 'Imath', 'IlmImf', 'z'],
+ extra_compile_args=['-g'])
+ ],
+ py_modules=['Imath'],
+ # scripts=['test-exr.py']
+)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/test-exr.py new/OpenEXR-1.0.3/test-exr.py
--- old/OpenEXR-1.0/test-exr.py 1970-01-01 01:00:00.000000000 +0100
+++ new/OpenEXR-1.0.3/test-exr.py 2009-08-21 20:54:25.000000000 +0200
@@ -0,0 +1,130 @@
+import unittest
+import random
+import array
+
+import Imath
+import OpenEXR
+
+class TestDirected(unittest.TestCase):
+
+ def setUp(self):
+ self.FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
+ self.UINT = Imath.PixelType(Imath.PixelType.UINT)
+ self.HALF = Imath.PixelType(Imath.PixelType.HALF)
+
+ def load_red(self, filename):
+ oexr = OpenEXR.InputFile(filename)
+ return oexr.channel('R')
+
+ def test_write_chunk(self):
+ """ Write the pixels to two images, first as a single call,
+ then as multiple calls. Verify that the images are identical.
+ """
+ for w,h,step in [(100, 10, 1), (64,48,6), (1, 100, 2), (640, 480, 4)]:
+ data = array.array('f', [ random.random() for x in range(w * h) ]).tostring()
+
+ hdr = OpenEXR.Header(w,h)
+ x = OpenEXR.OutputFile("out0.exr", hdr)
+ x.writePixels({'R': data, 'G': data, 'B': data})
+ x.close()
+
+ hdr = OpenEXR.Header(w,h)
+ x = OpenEXR.OutputFile("out1.exr", hdr)
+ for y in range(0, h, step):
+ subdata = data[y * w * 4:(y+step) * w * 4]
+ x.writePixels({'R': subdata, 'G': subdata, 'B': subdata}, step)
+ x.close()
+
+ oexr0 = self.load_red("out0.exr")
+ oexr1 = self.load_red("out1.exr")
+ self.assert_(oexr0 == oexr1)
+
+ def test_fail(self):
+ self.assertRaises(IOError, lambda: OpenEXR.InputFile("non-existent"))
+ hdr = OpenEXR.Header(640, 480)
+ self.assertRaises(IOError, lambda: OpenEXR.OutputFile("/forbidden", hdr))
+
+ def test_channel_channels(self):
+ """ Check that the channel method and channels method return the same data """
+ oexr = OpenEXR.InputFile("samples/openexr-images-1.5.0/ScanLines/MtTamWest.exr")
+ cl = sorted(oexr.header()['channels'].keys())
+ a = [oexr.channel(c) for c in cl]
+ b = oexr.channels(cl)
+ self.assert_(a == b)
+
+ def test_one(self):
+ oexr = OpenEXR.InputFile("samples/openexr-images-1.5.0/ScanLines/MtTamWest.exr")
+ for k,v in sorted(oexr.header().items()):
+ print "%20s: %s" % (k, v)
+ first_header = oexr.header()
+
+ default_size = len(oexr.channel('R'))
+ half_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.HALF)))
+ float_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.FLOAT)))
+ uint_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.UINT)))
+
+ self.assert_(default_size in [ half_size, float_size, uint_size])
+ self.assert_(float_size == uint_size)
+ self.assert_((float_size / 2) == half_size)
+
+ self.assert_(len(oexr.channel('R', pixel_type = self.FLOAT, scanLine1 = 10, scanLine2 = 10)) == (4 * (first_header['dataWindow'].max.x + 1)))
+
+ data = " " * (4 * 100 * 100)
+ h = OpenEXR.Header(100,100)
+ x = OpenEXR.OutputFile("out.exr", h)
+ x.writePixels({'R': data, 'G': data, 'B': data})
+ x.close()
+
+ def test_types(self):
+ for original in [ [0,0,0], range(10), range(100,200,3) ]:
+ for code,t in [ ('I', self.UINT), ('f', self.FLOAT) ]:
+ data = array.array(code, original).tostring()
+ hdr = OpenEXR.Header(len(original), 1)
+ hdr['channels'] = {'L': Imath.Channel(t)}
+
+ x = OpenEXR.OutputFile("out.exr", hdr)
+ x.writePixels({'L': data})
+ x.close()
+
+ xin = OpenEXR.InputFile("out.exr")
+ # Implicit type
+ self.assert_(array.array(code, xin.channel('L')).tolist() == original)
+ # Explicit type
+ self.assert_(array.array(code, xin.channel('L', t)).tolist() == original)
+ # Explicit type as kwarg
+ self.assert_(array.array(code, xin.channel('L', pixel_type = t)).tolist() == original)
+
+ def test_conversion(self):
+ """ Write an image as UINT, read as FLOAT. And the reverse. """
+ codemap = { 'f': self.FLOAT, 'I': self.UINT }
+ original = [0, 1, 33, 79218]
+ for frm_code,to_code in [ ('f','I'), ('I','f') ]:
+ hdr = OpenEXR.Header(len(original), 1)
+ hdr['channels'] = {'L': Imath.Channel(codemap[frm_code])}
+ x = OpenEXR.OutputFile("out.exr", hdr)
+ x.writePixels({'L': array.array(frm_code, original).tostring()})
+ x.close()
+
+ xin = OpenEXR.InputFile("out.exr")
+ self.assert_(array.array(to_code, xin.channel('L', codemap[to_code])).tolist() == original)
+
+ def test_leak(self):
+ hdr = OpenEXR.Header(10, 10)
+ data = array.array('f', [ 0.1 ] * (10 * 10)).tostring()
+ for i in range(1000):
+ x = OpenEXR.OutputFile("out.exr", hdr)
+ x.writePixels({'R': data, 'G': data, 'B': data})
+ x.close()
+ return
+
+ for i in range(1000):
+ oexr = OpenEXR.InputFile("out.exr")
+ h = oexr.header()
+
+if __name__ == '__main__':
+ if 1:
+ unittest.main()
+ else:
+ suite = unittest.TestSuite()
+ suite.addTest(TestDirected('test_one'))
+ unittest.TextTestRunner(verbosity=2).run(suite)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenEXR-1.0/test.py new/OpenEXR-1.0.3/test.py
--- old/OpenEXR-1.0/test.py 2009-05-26 05:03:23.000000000 +0200
+++ new/OpenEXR-1.0.3/test.py 1970-01-01 01:00:00.000000000 +0100
@@ -1,116 +0,0 @@
-import unittest
-import Imath
-import OpenEXR
-import random
-import array
-
-class TestDirected(unittest.TestCase):
-
- def setUp(self):
- self.FLOAT = Imath.PixelType(Imath.PixelType.FLOAT)
- self.UINT = Imath.PixelType(Imath.PixelType.UINT)
- self.HALF = Imath.PixelType(Imath.PixelType.HALF)
-
- def load_red(self, filename):
- oexr = OpenEXR.InputFile(filename)
- return oexr.channel('R')
-
- def test_write_chunk(self):
- """ Write the pixels to two images, first as a single call,
- then as multiple calls. Verify that the images are identical.
- """
- for w,h,step in [(100, 10, 1), (64,48,6), (1, 100, 2), (640, 480, 4)]:
- data = array.array('f', [ random.random() for x in range(w * h) ]).tostring()
-
- hdr = OpenEXR.Header(w,h)
- x = OpenEXR.OutputFile("out0.exr", hdr)
- x.writePixels({'R': data, 'G': data, 'B': data})
- x.close()
-
- hdr = OpenEXR.Header(w,h)
- x = OpenEXR.OutputFile("out1.exr", hdr)
- for y in range(0, h, step):
- subdata = data[y * w * 4:(y+step) * w * 4]
- x.writePixels({'R': subdata, 'G': subdata, 'B': subdata}, step)
- x.close()
-
- oexr0 = self.load_red("out0.exr")
- oexr1 = self.load_red("out1.exr")
- self.assert_(oexr0 == oexr1)
-
- def test_one(self):
- oexr = OpenEXR.InputFile("MtTamWest.exr")
- for k,v in sorted(oexr.header().items()):
- print "%20s: %s" % (k, v)
- first_header = oexr.header()
-
- default_size = len(oexr.channel('R'))
- half_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.HALF)))
- float_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.FLOAT)))
- uint_size = len(oexr.channel('R', Imath.PixelType(Imath.PixelType.UINT)))
-
- self.assert_(default_size in [ half_size, float_size, uint_size])
- self.assert_(float_size == uint_size)
- self.assert_((float_size / 2) == half_size)
-
- self.assert_(len(oexr.channel('R', pixel_type = self.FLOAT, scanLine1 = 10, scanLine2 = 10)) == (4 * (first_header['dataWindow'].max.x + 1)))
-
- data = " " * (4 * 100 * 100)
- h = OpenEXR.Header(100,100)
- x = OpenEXR.OutputFile("out.exr", h)
- x.writePixels({'R': data, 'G': data, 'B': data})
- x.close()
-
- def test_types(self):
- for original in [ [0,0,0], range(10), range(100,200,3) ]:
- for code,t in [ ('I', self.UINT), ('f', self.FLOAT) ]:
- data = array.array(code, original).tostring()
- hdr = OpenEXR.Header(len(original), 1)
- hdr['channels'] = {'L': Imath.Channel(t)}
-
- x = OpenEXR.OutputFile("out.exr", hdr)
- x.writePixels({'L': data})
- x.close()
-
- xin = OpenEXR.InputFile("out.exr")
- # Implicit type
- self.assert_(array.array(code, xin.channel('L')).tolist() == original)
- # Explicit type
- self.assert_(array.array(code, xin.channel('L', t)).tolist() == original)
- # Explicit type as kwarg
- self.assert_(array.array(code, xin.channel('L', pixel_type = t)).tolist() == original)
-
- def test_conversion(self):
- """ Write an image as UINT, read as FLOAT. And the reverse. """
- codemap = { 'f': self.FLOAT, 'I': self.UINT }
- original = [0, 1, 33, 79218]
- for frm_code,to_code in [ ('f','I'), ('I','f') ]:
- hdr = OpenEXR.Header(len(original), 1)
- hdr['channels'] = {'L': Imath.Channel(codemap[frm_code])}
- x = OpenEXR.OutputFile("out.exr", hdr)
- x.writePixels({'L': array.array(frm_code, original).tostring()})
- x.close()
-
- xin = OpenEXR.InputFile("out.exr")
- self.assert_(array.array(to_code, xin.channel('L', codemap[to_code])).tolist() == original)
-
- def test_leak(self):
- hdr = OpenEXR.Header(10, 10)
- data = array.array('f', [ 0.1 ] * (10 * 10)).tostring()
- for i in range(1000):
- x = OpenEXR.OutputFile("out.exr", hdr)
- x.writePixels({'R': data, 'G': data, 'B': data})
- x.close()
- return
-
- for i in range(1000):
- oexr = OpenEXR.InputFile("out.exr")
- h = oexr.header()
-
-if __name__ == '__main__':
- if 1:
- unittest.main()
- else:
- suite = unittest.TestSuite()
- suite.addTest(TestDirected('test_one'))
- unittest.TextTestRunner(verbosity=2).run(suite)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org