diff options
Diffstat (limited to 'graphics/exact-image')
-rw-r--r-- | graphics/exact-image/Provide-gif-quantization-for-giflib-5.2.patch | 384 | ||||
-rw-r--r-- | graphics/exact-image/README | 17 | ||||
-rw-r--r-- | graphics/exact-image/exact-image.SlackBuild | 28 |
3 files changed, 415 insertions, 14 deletions
diff --git a/graphics/exact-image/Provide-gif-quantization-for-giflib-5.2.patch b/graphics/exact-image/Provide-gif-quantization-for-giflib-5.2.patch new file mode 100644 index 0000000000..9f9210abf5 --- /dev/null +++ b/graphics/exact-image/Provide-gif-quantization-for-giflib-5.2.patch @@ -0,0 +1,384 @@ +From: Sven Eckelmann <sven@narfation.org> +Date: Sat, 31 Aug 2019 14:13:11 +0200 +Subject: Provide gif quantization for giflib >= 5.2 + +Bug-Debian: https://bugs.debian.org/939031 + +diff -Naur exact-image-1.0.2.orig/codecs/Makefile exact-image-1.0.2/codecs/Makefile +--- exact-image-1.0.2.orig/codecs/Makefile 2016-06-18 21:49:25.000000000 +0200 ++++ exact-image-1.0.2/codecs/Makefile 2020-12-11 15:30:44.374504000 +0100 +@@ -21,7 +21,7 @@ + ifeq "$(WITHLIBGIF)" "1" + LDFLAGS += -lgif + else +-NOT_SRCS += gif.cc ++NOT_SRCS += gif.cc gif_quantization.c + endif + + ifeq "$(WITHJASPER)" "1" +diff -Naur exact-image-1.0.2.orig/codecs/gif.cc exact-image-1.0.2/codecs/gif.cc +--- exact-image-1.0.2.orig/codecs/gif.cc 2017-07-21 16:19:01.000000000 +0200 ++++ exact-image-1.0.2/codecs/gif.cc 2020-12-11 15:34:55.340504000 +0100 +@@ -160,6 +160,17 @@ + return true; + } + ++extern "C" int ++eiGifQuantizeBuffer(unsigned int Width, ++ unsigned int Height, ++ int *ColorMapSize, ++ GifByteType * RedInput, ++ GifByteType * GreenInput, ++ GifByteType * BlueInput, ++ GifByteType * OutputBuffer, ++ GifColorType * OutputColorMap); ++ ++ + bool GIFCodec::writeImage (std::ostream* stream, Image& image, int quality, + const std::string& compress) + { +@@ -203,8 +214,7 @@ + *bptr++ = b; + } + +- +- if (GifQuantizeBuffer(image.w, image.h, &ColorMapSize, ++ if (eiGifQuantizeBuffer(image.w, image.h, &ColorMapSize, + RedBuffer, GreenBuffer, BlueBuffer, + OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) { + return false; +diff -Naur exact-image-1.0.2.orig/codecs/gif_quantization.c exact-image-1.0.2/codecs/gif_quantization.c +--- exact-image-1.0.2.orig/codecs/gif_quantization.c 1970-01-01 01:00:00.000000000 +0100 ++++ exact-image-1.0.2/codecs/gif_quantization.c 2020-12-11 15:30:19.181504000 +0100 +@@ -0,0 +1,331 @@ ++/***************************************************************************** ++ ++ quantize.c - quantize a high resolution image into lower one ++ ++ Based on: "Color Image Quantization for frame buffer Display", by ++ Paul Heckbert SIGGRAPH 1982 page 297-307. ++ ++ This doesn't really belong in the core library, was undocumented, ++ and was removed in 4.2. Then it turned out some client apps were ++ actually using it, so it was restored in 5.0. ++ ++SPDX-License-Identifier: MIT ++ ++******************************************************************************/ ++ ++#include <stdlib.h> ++#include <stdio.h> ++#include "gif_lib.h" ++ ++#define ABS(x) ((x) > 0 ? (x) : (-(x))) ++ ++#define COLOR_ARRAY_SIZE 32768 ++#define BITS_PER_PRIM_COLOR 5 ++#define MAX_PRIM_COLOR 0x1f ++ ++static int SortRGBAxis; ++ ++typedef struct QuantizedColorType { ++ GifByteType RGB[3]; ++ GifByteType NewColorIndex; ++ long Count; ++ struct QuantizedColorType *Pnext; ++} QuantizedColorType; ++ ++typedef struct NewColorMapType { ++ GifByteType RGBMin[3], RGBWidth[3]; ++ unsigned int NumEntries; /* # of QuantizedColorType in linked list below */ ++ unsigned long Count; /* Total number of pixels in all the entries */ ++ QuantizedColorType *QuantizedColors; ++} NewColorMapType; ++ ++static int SubdivColorMap(NewColorMapType * NewColorSubdiv, ++ unsigned int ColorMapSize, ++ unsigned int *NewColorMapSize); ++static int SortCmpRtn(const void *Entry1, const void *Entry2); ++ ++/****************************************************************************** ++ Quantize high resolution image into lower one. Input image consists of a ++ 2D array for each of the RGB colors with size Width by Height. There is no ++ Color map for the input. Output is a quantized image with 2D array of ++ indexes into the output color map. ++ Note input image can be 24 bits at the most (8 for red/green/blue) and ++ the output has 256 colors at the most (256 entries in the color map.). ++ ColorMapSize specifies size of color map up to 256 and will be updated to ++ real size before returning. ++ Also non of the parameter are allocated by this routine. ++ This function returns GIF_OK if successful, GIF_ERROR otherwise. ++******************************************************************************/ ++int ++eiGifQuantizeBuffer(unsigned int Width, ++ unsigned int Height, ++ int *ColorMapSize, ++ GifByteType * RedInput, ++ GifByteType * GreenInput, ++ GifByteType * BlueInput, ++ GifByteType * OutputBuffer, ++ GifColorType * OutputColorMap) { ++ ++ unsigned int Index, NumOfEntries; ++ int i, j, MaxRGBError[3]; ++ unsigned int NewColorMapSize; ++ long Red, Green, Blue; ++ NewColorMapType NewColorSubdiv[256]; ++ QuantizedColorType *ColorArrayEntries, *QuantizedColor; ++ ++ ColorArrayEntries = (QuantizedColorType *)malloc( ++ sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE); ++ if (ColorArrayEntries == NULL) { ++ return GIF_ERROR; ++ } ++ ++ for (i = 0; i < COLOR_ARRAY_SIZE; i++) { ++ ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR); ++ ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) & ++ MAX_PRIM_COLOR; ++ ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR; ++ ColorArrayEntries[i].Count = 0; ++ } ++ ++ /* Sample the colors and their distribution: */ ++ for (i = 0; i < (int)(Width * Height); i++) { ++ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << ++ (2 * BITS_PER_PRIM_COLOR)) + ++ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << ++ BITS_PER_PRIM_COLOR) + ++ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR)); ++ ColorArrayEntries[Index].Count++; ++ } ++ ++ /* Put all the colors in the first entry of the color map, and call the ++ * recursive subdivision process. */ ++ for (i = 0; i < 256; i++) { ++ NewColorSubdiv[i].QuantizedColors = NULL; ++ NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0; ++ for (j = 0; j < 3; j++) { ++ NewColorSubdiv[i].RGBMin[j] = 0; ++ NewColorSubdiv[i].RGBWidth[j] = 255; ++ } ++ } ++ ++ /* Find the non empty entries in the color table and chain them: */ ++ for (i = 0; i < COLOR_ARRAY_SIZE; i++) ++ if (ColorArrayEntries[i].Count > 0) ++ break; ++ QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i]; ++ NumOfEntries = 1; ++ while (++i < COLOR_ARRAY_SIZE) ++ if (ColorArrayEntries[i].Count > 0) { ++ QuantizedColor->Pnext = &ColorArrayEntries[i]; ++ QuantizedColor = &ColorArrayEntries[i]; ++ NumOfEntries++; ++ } ++ QuantizedColor->Pnext = NULL; ++ ++ NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */ ++ NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */ ++ NewColorMapSize = 1; ++ if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) != ++ GIF_OK) { ++ free((char *)ColorArrayEntries); ++ return GIF_ERROR; ++ } ++ if (NewColorMapSize < *ColorMapSize) { ++ /* And clear rest of color map: */ ++ for (i = NewColorMapSize; i < *ColorMapSize; i++) ++ OutputColorMap[i].Red = OutputColorMap[i].Green = ++ OutputColorMap[i].Blue = 0; ++ } ++ ++ /* Average the colors in each entry to be the color to be used in the ++ * output color map, and plug it into the output color map itself. */ ++ for (i = 0; i < NewColorMapSize; i++) { ++ if ((j = NewColorSubdiv[i].NumEntries) > 0) { ++ QuantizedColor = NewColorSubdiv[i].QuantizedColors; ++ Red = Green = Blue = 0; ++ while (QuantizedColor) { ++ QuantizedColor->NewColorIndex = i; ++ Red += QuantizedColor->RGB[0]; ++ Green += QuantizedColor->RGB[1]; ++ Blue += QuantizedColor->RGB[2]; ++ QuantizedColor = QuantizedColor->Pnext; ++ } ++ OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j; ++ OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j; ++ OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j; ++ } ++ } ++ ++ /* Finally scan the input buffer again and put the mapped index in the ++ * output buffer. */ ++ MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0; ++ for (i = 0; i < (int)(Width * Height); i++) { ++ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << ++ (2 * BITS_PER_PRIM_COLOR)) + ++ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << ++ BITS_PER_PRIM_COLOR) + ++ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR)); ++ Index = ColorArrayEntries[Index].NewColorIndex; ++ OutputBuffer[i] = Index; ++ if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i])) ++ MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]); ++ if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i])) ++ MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]); ++ if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i])) ++ MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]); ++ } ++ ++#ifdef DEBUG ++ fprintf(stderr, ++ "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n", ++ MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]); ++#endif /* DEBUG */ ++ ++ free((char *)ColorArrayEntries); ++ ++ *ColorMapSize = NewColorMapSize; ++ ++ return GIF_OK; ++} ++ ++/****************************************************************************** ++ Routine to subdivide the RGB space recursively using median cut in each ++ axes alternatingly until ColorMapSize different cubes exists. ++ The biggest cube in one dimension is subdivide unless it has only one entry. ++ Returns GIF_ERROR if failed, otherwise GIF_OK. ++*******************************************************************************/ ++static int ++SubdivColorMap(NewColorMapType * NewColorSubdiv, ++ unsigned int ColorMapSize, ++ unsigned int *NewColorMapSize) { ++ ++ unsigned int i, j, Index = 0; ++ QuantizedColorType *QuantizedColor, **SortArray; ++ ++ while (ColorMapSize > *NewColorMapSize) { ++ /* Find candidate for subdivision: */ ++ long Sum, Count; ++ int MaxSize = -1; ++ unsigned int NumEntries, MinColor, MaxColor; ++ for (i = 0; i < *NewColorMapSize; i++) { ++ for (j = 0; j < 3; j++) { ++ if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) && ++ (NewColorSubdiv[i].NumEntries > 1)) { ++ MaxSize = NewColorSubdiv[i].RGBWidth[j]; ++ Index = i; ++ SortRGBAxis = j; ++ } ++ } ++ } ++ ++ if (MaxSize == -1) ++ return GIF_OK; ++ ++ /* Split the entry Index into two along the axis SortRGBAxis: */ ++ ++ /* Sort all elements in that entry along the given axis and split at ++ * the median. */ ++ SortArray = (QuantizedColorType **)malloc( ++ sizeof(QuantizedColorType *) * ++ NewColorSubdiv[Index].NumEntries); ++ if (SortArray == NULL) ++ return GIF_ERROR; ++ for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors; ++ j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL; ++ j++, QuantizedColor = QuantizedColor->Pnext) ++ SortArray[j] = QuantizedColor; ++ ++ /* ++ * Because qsort isn't stable, this can produce differing ++ * results for the order of tuples depending on platform ++ * details of how qsort() is implemented. ++ * ++ * We mitigate this problem by sorting on all three axes rather ++ * than only the one specied by SortRGBAxis; that way the instability ++ * can only become an issue if there are multiple color indices ++ * referring to identical RGB tuples. Older versions of this ++ * sorted on only the one axis. ++ */ ++ qsort(SortArray, NewColorSubdiv[Index].NumEntries, ++ sizeof(QuantizedColorType *), SortCmpRtn); ++ ++ /* Relink the sorted list into one: */ ++ for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++) ++ SortArray[j]->Pnext = SortArray[j + 1]; ++ SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL; ++ NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0]; ++ free((char *)SortArray); ++ ++ /* Now simply add the Counts until we have half of the Count: */ ++ Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count; ++ NumEntries = 1; ++ Count = QuantizedColor->Count; ++ while (QuantizedColor->Pnext != NULL && ++ (Sum -= QuantizedColor->Pnext->Count) >= 0 && ++ QuantizedColor->Pnext->Pnext != NULL) { ++ QuantizedColor = QuantizedColor->Pnext; ++ NumEntries++; ++ Count += QuantizedColor->Count; ++ } ++ /* Save the values of the last color of the first half, and first ++ * of the second half so we can update the Bounding Boxes later. ++ * Also as the colors are quantized and the BBoxes are full 0..255, ++ * they need to be rescaled. ++ */ ++ MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */ ++ /* coverity[var_deref_op] */ ++ MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */ ++ MaxColor <<= (8 - BITS_PER_PRIM_COLOR); ++ MinColor <<= (8 - BITS_PER_PRIM_COLOR); ++ ++ /* Partition right here: */ ++ NewColorSubdiv[*NewColorMapSize].QuantizedColors = ++ QuantizedColor->Pnext; ++ QuantizedColor->Pnext = NULL; ++ NewColorSubdiv[*NewColorMapSize].Count = Count; ++ NewColorSubdiv[Index].Count -= Count; ++ NewColorSubdiv[*NewColorMapSize].NumEntries = ++ NewColorSubdiv[Index].NumEntries - NumEntries; ++ NewColorSubdiv[Index].NumEntries = NumEntries; ++ for (j = 0; j < 3; j++) { ++ NewColorSubdiv[*NewColorMapSize].RGBMin[j] = ++ NewColorSubdiv[Index].RGBMin[j]; ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[j] = ++ NewColorSubdiv[Index].RGBWidth[j]; ++ } ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] = ++ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] + ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor; ++ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor; ++ ++ NewColorSubdiv[Index].RGBWidth[SortRGBAxis] = ++ MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis]; ++ ++ (*NewColorMapSize)++; ++ } ++ ++ return GIF_OK; ++} ++ ++/**************************************************************************** ++ Routine called by qsort to compare two entries. ++*****************************************************************************/ ++ ++static int ++SortCmpRtn(const void *Entry1, ++ const void *Entry2) { ++ QuantizedColorType *entry1 = (*((QuantizedColorType **) Entry1)); ++ QuantizedColorType *entry2 = (*((QuantizedColorType **) Entry2)); ++ ++ /* sort on all axes of the color space! */ ++ int hash1 = entry1->RGB[SortRGBAxis] * 256 * 256 ++ + entry1->RGB[(SortRGBAxis+1) % 3] * 256 ++ + entry1->RGB[(SortRGBAxis+2) % 3]; ++ int hash2 = entry2->RGB[SortRGBAxis] * 256 * 256 ++ + entry2->RGB[(SortRGBAxis+1) % 3] * 256 ++ + entry2->RGB[(SortRGBAxis+2) % 3]; ++ ++ return hash1 - hash2; ++} ++ ++/* end */ diff --git a/graphics/exact-image/README b/graphics/exact-image/README index 8a29a3099d..c11dba9e4a 100644 --- a/graphics/exact-image/README +++ b/graphics/exact-image/README @@ -1,12 +1,15 @@ -ExactImage is an image processing library which reimplements +ExactImage is an image processing library which reimplements ImageMagick functions with a significant speed improvement. The library also provides several new algorithms: lossless JPEG -transforms and creation of searchable PDFs from hOCR annotated -HTML created with an OCR program such as Tesseract or Cuneiform -(available at Slackbuilds.org). There are bindings for PHP, Lua, -Perl, and Python. See /usr/doc/exact-image-*/examples/ for -information on using exactimage with Perl, Python, PHP and Lua. +transforms and creation of searchable PDFs from hOCR annotated HTML +created with an OCR program such as Tesseract or Cuneiform (available +at Slackbuilds.org). There are bindings for PHP[*], Lua, Perl, and +Python. See /usr/doc/exact-image-*/examples/ for information on using +exactimage with Perl, Python, PHP[*] and Lua. -lua and evas are optional dependencies. +lua is an optional dependency. bardecode is also optional but not available at SBo. + +[*] The PHP extension is disabled in this SlackBuild, as it only + supports PHP5, and we have PHP7 on Slackware 15.0. Sorry. diff --git a/graphics/exact-image/exact-image.SlackBuild b/graphics/exact-image/exact-image.SlackBuild index bc64a31f5b..7e8fdb3865 100644 --- a/graphics/exact-image/exact-image.SlackBuild +++ b/graphics/exact-image/exact-image.SlackBuild @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for exact-image -# Copyright 2010-2019 Benjamin Trigona-Harany <slackbuilds@jaxartes.net> +# Copyright 2010-2021 Benjamin Trigona-Harany <slackbuilds@jaxartes.net> # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -22,10 +22,18 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# 20220222 bkw: Modified by SlackBuilds.org: +# - enable libgif, openexr, python support. +# - disable evas support. requires efl, but build fails if efl is installed. +# - php is still disabled, but at least mention that in README. + +cd $(dirname $0) ; CWD=$(pwd) + PRGNAM=exact-image VERSION=${VERSION:-1.0.2} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in @@ -35,7 +43,11 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} @@ -65,20 +77,22 @@ cd $PRGNAM-$VERSION chown -R root:root . find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ - -o -perm 511 \) -exec chmod 755 {} \; -o \ + -o -perm 511 \) -exec chmod 755 {} \+ -o \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ - -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+ # Patch to fix perl path eval $(perl -V:vendorlib) sed "s,@vendorlib@,$vendorlib,g" $CWD/fixup-perl_paths.diff | patch -p1 --verbose patch -p1 < $CWD/c98.patch +patch -p1 < $CWD/Provide-gif-quantization-for-giflib-5.2.patch ./configure \ --bindir=/usr/bin \ --libdir=/usr/lib${LIBDIRSUFFIX} \ - --without-php + --without-php \ + --without-evas make CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS -Wno-narrowing -fpermissive" make install DESTDIR=$PKG @@ -96,4 +110,4 @@ mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cd $PKG -/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE |