Commit 65f0512f authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add support for ICC profiles

parent 246d34f2
......@@ -42,6 +42,7 @@ class RequiredToolNotFound(Exception):
PROVIDERS = { 'bzip2': { 'debian': 'bzip2',
'arch': 'bzip2'}
, 'cbfstool': {}
, 'cd-iccdump': { 'debian': 'colord' }
, 'cmp': { 'debian': 'diffutils',
'arch': 'diffutils'}
, 'cpio': { 'debian': 'cpio',
......
......@@ -52,6 +52,7 @@ from diffoscope.comparators.fonts import TtfFile
from diffoscope.comparators.gettext import MoFile
from diffoscope.comparators.gzip import GzipFile
from diffoscope.comparators.haskell import HiFile
from diffoscope.comparators.icc import IccFile
from diffoscope.comparators.image import ImageFile
from diffoscope.comparators.ipk import IpkFile
from diffoscope.comparators.iso9660 import Iso9660File
......@@ -146,6 +147,7 @@ FILE_CLASSES = (
IpkFile,
GzipFile,
HiFile,
IccFile,
Iso9660File,
ClassFile,
MonoExeFile,
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2016 Jérémy Bobbio <lunar@debian.org>
#
# diffoscope 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.
#
# diffoscope 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 diffoscope. If not, see <http://www.gnu.org/licenses/>.
import re
from diffoscope import tool_required
from diffoscope.comparators.binary import File
from diffoscope.comparators.utils import Command
from diffoscope.difference import Difference
class Iccdump(Command):
@tool_required('cd-iccdump')
def cmdline(self):
return ['cd-iccdump', self.path]
class IccFile(File):
RE_FILE_EXTENSION = re.compile(r'\bICC Profile$')
@staticmethod
def recognizes(file):
return IccFile.RE_FILE_EXTENSION.search(file.magic_file_type)
def compare_details(self, other, source=None):
return [Difference.from_command(Iccdump, self.path, other.path)]
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2016 Jérémy Bobbio <lunar@debian.org>
#
# diffoscope 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.
#
# diffoscope 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 diffoscope. If not, see <http://www.gnu.org/licenses/>.
import os.path
import pytest
from diffoscope.comparators import specialize
from diffoscope.comparators.binary import FilesystemFile, NonExistingFile
from diffoscope.comparators.icc import IccFile
from diffoscope.config import Config
from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.icc')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.icc')
@pytest.fixture
def icc1():
return specialize(FilesystemFile(TEST_FILE1_PATH))
@pytest.fixture
def icc2():
return specialize(FilesystemFile(TEST_FILE2_PATH))
def test_identification(icc1):
assert isinstance(icc1, IccFile)
def test_no_differences(icc1):
difference = icc1.compare(icc1)
assert difference is None
@pytest.fixture
def differences(icc1, icc2):
return icc1.compare(icc2).details
@pytest.mark.skipif(tool_missing('cd-iccdump'), reason='missing cd-iccdump')
def test_diff(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/icc_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
@pytest.mark.skipif(tool_missing('cd-iccdump'), reason='missing cd-iccdump')
def test_compare_non_existing(monkeypatch, icc1):
monkeypatch.setattr(Config, 'new_file', True)
difference = icc1.compare(NonExistingFile('/nonexisting', icc1))
assert difference.source2 == '/nonexisting'
assert len(difference.details) > 0
@@ -1,20 +1,20 @@
icc:
Header:
Size = 14684 bytes
Version = 4.3
Profile Kind = display-device
Colorspace = rgb
Conn. Space = xyz
- Date, Time = 2016-02-15, 21:02:09
+ Date, Time = 2016-02-15, 21:03:22
Flags = Not embedded profile, Use anywhere
Dev. Attrbts = reflective, glossy
Rndrng Intnt = perceptual
Creator = lcms
- Profile ID = 0x0477fa4b
+ Profile ID = 0x06017f17
tag 00:
sig 'desc' [0x64657363]
size 38
type 'mluc' [0x6d6c7563]
Text:
en_US: sRGB [24 bytes]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment