From bec6b174c99bb8121318834b79618cf948447ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= Date: Sun, 8 May 2016 22:39:08 +0200 Subject: [PATCH 1/2] Fix poppler version requirement, add loader check This fixes the poppler-glib version requirement to version 0.16, which is the lowest version that compiles and works properly with pdfload. Also added a check for pdfload and enabled testing on Travis CI. --- .travis.yml | 2 +- configure.ac | 8 ++++---- test/images/blankpage.pdf | 37 +++++++++++++++++++++++++++++++++++++ test/images/blankpage.png | Bin 0 -> 3795 bytes test/test_formats.sh | 8 ++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100755 test/images/blankpage.pdf create mode 100644 test/images/blankpage.png diff --git a/.travis.yml b/.travis.yml index d7d39749..2ca5238d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_install: - sudo apt-get install libpng12-dev libwebp-dev libtiff4-dev libxml2-dev - sudo apt-get install swig libmagick++-dev bc - sudo apt-get install libcfitsio3-dev libgsl0-dev libmatio-dev - - sudo apt-get install liborc-0.4-dev liblcms2-dev + - sudo apt-get install liborc-0.4-dev liblcms2-dev libpoppler-glib-dev before_script: - ./bootstrap.sh - ./configure diff --git a/configure.ac b/configure.ac index 4ddb37fe..7aecb252 100644 --- a/configure.ac +++ b/configure.ac @@ -563,12 +563,12 @@ AC_ARG_WITH([poppler], AS_HELP_STRING([--without-poppler], [build without poppler (default: test)])) if test x"$with_poppler" != x"no"; then - PKG_CHECK_MODULES(POPPLER, [poppler-glib >= 0.30.0 cairo >= 1.2], - [AC_DEFINE(HAVE_POPPLER,1,[define if you have poppler-glib >= 0.30.0 and cairo >= 1.2 installed.]) + PKG_CHECK_MODULES(POPPLER, [poppler-glib >= 0.16.0 cairo >= 1.2], + [AC_DEFINE(HAVE_POPPLER,1,[define if you have poppler-glib >= 0.16.0 and cairo >= 1.2 installed.]) with_poppler=yes PACKAGES_USED="$PACKAGES_USED poppler-glib cairo" ], - [AC_MSG_WARN([poppler-glib >= 0.30.0 or cairo >= 1.2 not found; disabling PDF load via poppler]) + [AC_MSG_WARN([poppler-glib >= 0.16.0 or cairo >= 1.2 not found; disabling PDF load via poppler]) with_poppler=no ] ) @@ -961,7 +961,7 @@ file import with OpenSlide: $with_openslide (requires openslide-3.3.0 or later) file import with matio: $with_matio PDF import with poppler-glib: $with_poppler - (requires poppler-glib 0.30.0 or later) + (requires poppler-glib 0.16.0 or later) SVG import with librsvg-2.0: $with_rsvg (requires librsvg-2.0 2.40.0 or later) file import with cfitsio: $with_cfitsio diff --git a/test/images/blankpage.pdf b/test/images/blankpage.pdf new file mode 100755 index 00000000..5884469c --- /dev/null +++ b/test/images/blankpage.pdf @@ -0,0 +1,37 @@ +%PDF-1.1 +%âãÏÓ +1 0 obj +<< +/Pages 2 0 R +/Type /Catalog +>> +endobj +2 0 obj +<< +/MediaBox [0 0 595 842] +/Kids [3 0 R] +/Count 1 +/Type /Pages +>> +endobj +3 0 obj +<< +/Parent 2 0 R +/MediaBox [0 0 595 842] +/Type /Page +>> +endobj xref +0 4 +0000000000 65535 f +0000000015 00000 n +0000000066 00000 n +0000000149 00000 n +trailer + +<< +/Root 1 0 R +/Size 4 +>> +startxref +221 +%%EOF diff --git a/test/images/blankpage.png b/test/images/blankpage.png new file mode 100644 index 0000000000000000000000000000000000000000..00478276b6c929424245b9540189366b020172a3 GIT binary patch literal 3795 zcmeAS@N?(olHy`uVBq!ia0y~yUl5RScXGVsCl)HQk3>7nHGBI$R z5n*shSOzrQn3X|bh9*P90Ut&NmNYH~1p}aUjiX9N!(}uvjAoM2l3}zs9IYls>&DRr t!DvHiv~@VzY98$>jP{T4^cxSd^|f?V9|6c$A literal 0 HcmV?d00001 diff --git a/test/test_formats.sh b/test/test_formats.sh index 72af1ad4..bce44af1 100755 --- a/test/test_formats.sh +++ b/test/test_formats.sh @@ -7,6 +7,10 @@ . ./variables.sh +# poppler / pdfload reference image +poppler=$test_images/blankpage.pdf +poppler_ref=$test_images/blankpage.png + # the matlab image and reference image matlab=$test_images/sample.mat matlab_ref=$test_images/sample.png @@ -215,6 +219,10 @@ test_rad $rad test_raw $mono test_raw $image +if test_supported pdfload; then + test_loader $poppler_ref $poppler pdfload +fi + if test_supported matload; then test_loader $matlab_ref $matlab matlab fi From 6418ab230757b36a831019972f24cfa6db54cbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= Date: Sun, 8 May 2016 23:26:10 +0200 Subject: [PATCH 2/2] Extract shared pdfload/svgload code into cairo.c --- libvips/foreign/Makefile.am | 1 + libvips/foreign/cairo.c | 68 +++++++++++++++++++++++++++++++++++++ libvips/foreign/svgload.c | 28 --------------- 3 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 libvips/foreign/cairo.c diff --git a/libvips/foreign/Makefile.am b/libvips/foreign/Makefile.am index 004ba7f4..f1ccb01e 100644 --- a/libvips/foreign/Makefile.am +++ b/libvips/foreign/Makefile.am @@ -2,6 +2,7 @@ noinst_LTLIBRARIES = libforeign.la libforeign_la_SOURCES = \ gifload.c \ + cairo.c \ pdfload.c \ svgload.c \ radiance.h \ diff --git a/libvips/foreign/cairo.c b/libvips/foreign/cairo.c new file mode 100644 index 00000000..f8f6dec5 --- /dev/null +++ b/libvips/foreign/cairo.c @@ -0,0 +1,68 @@ +/* Shared code for cairo based loaders like svgload and pdfload. + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ + +#if defined(HAVE_RSVG) || defined(HAVE_POPPLER) + +#include +#include + +/* Convert from ARGB to RGBA and undo premultiplication. + */ +void +vips__cairo2rgba( guint32 * restrict buf, int n ) +{ + int i; + + for( i = 0; i < n; i++ ) { + guint32 * restrict p = buf + i; + guint32 x = *p; + guint8 a = x >> 24; + VipsPel * restrict out = (VipsPel *) p; + + if( a == 255 ) + *p = GUINT32_TO_BE( (x << 8) | 255 ); + else if( a == 0 ) + *p = GUINT32_TO_BE( x << 8 ); + else { + /* Undo premultiplication. + */ + out[0] = 255 * ((x >> 16) & 255) / a; + out[1] = 255 * ((x >> 8) & 255) / a; + out[2] = 255 * (x & 255) / a; + out[3] = a; + } + } +} + +#endif diff --git a/libvips/foreign/svgload.c b/libvips/foreign/svgload.c index 929b7a64..7b41e31a 100644 --- a/libvips/foreign/svgload.c +++ b/libvips/foreign/svgload.c @@ -149,34 +149,6 @@ vips_foreign_load_svg_header( VipsForeignLoad *load ) return( 0 ); } -/* Convert from ARGB to RGBA and undo premultiplication. - */ -void -vips__cairo2rgba( guint32 * restrict buf, int n ) -{ - int i; - - for( i = 0; i < n; i++ ) { - guint32 * restrict p = buf + i; - guint32 x = *p; - guint8 a = x >> 24; - VipsPel * restrict out = (VipsPel *) p; - - if( a == 255 ) - *p = GUINT32_TO_BE( (x << 8) | 255 ); - else if( a == 0 ) - *p = GUINT32_TO_BE( x << 8 ); - else { - /* Undo premultiplication. - */ - out[0] = 255 * ((x >> 16) & 255) / a; - out[1] = 255 * ((x >> 8) & 255) / a; - out[2] = 255 * (x & 255) / a; - out[3] = a; - } - } -} - static int vips_foreign_load_svg_generate( VipsRegion *or, void *seq, void *a, void *b, gboolean *stop )