diff options
| author | Misty De Meo | 2011-09-30 10:01:15 -0500 | 
|---|---|---|
| committer | Charlie Sharpsteen | 2011-09-30 11:39:56 -0700 | 
| commit | 04a36c72c63f996b4f0bf6a892e18ff8b286101c (patch) | |
| tree | 66c882ef9857ac7e1a3cee204ee8be58a8fba9f3 /Library | |
| parent | 150351e3606df88c2414b8b30fe379b51cda0f4c (diff) | |
| download | homebrew-04a36c72c63f996b4f0bf6a892e18ff8b286101c.tar.bz2 | |
jbig2enc: Add patch to retain DPI
jbig2enc's pdf.py demo program did not properly retain an image's DPI
when creating a PDF; it was hardcoded to 600, regardless of the actual
resolution of the input image. This patch corrects that by intelligently
extracting the DPI from the file being converted.
Closes #7913.
Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Formula/jbig2enc.rb | 37 | 
1 files changed, 36 insertions, 1 deletions
diff --git a/Library/Formula/jbig2enc.rb b/Library/Formula/jbig2enc.rb index 8cec79dd3..15f2ec460 100644 --- a/Library/Formula/jbig2enc.rb +++ b/Library/Formula/jbig2enc.rb @@ -12,6 +12,8 @@ class Jbig2enc < Formula    def patches      # jbig2enc hardcodes the include and libraries paths.      # Fixing them up for Homebrew +    # Also contains a patch to pdf.py that retains DPI: +    # https://github.com/agl/jbig2enc/issues/15      DATA    end @@ -24,7 +26,7 @@ end  __END__  diff --git a/Makefile b/Makefile -index 0553375..e728c40 100644 +index dbb4556..aac8101 100644  --- a/Makefile  +++ b/Makefile  @@ -1,11 +1,11 @@ @@ -42,3 +44,36 @@ index 0553375..e728c40 100644   libjbig2enc.a: jbig2enc.o jbig2arith.o jbig2sym.o   	ar -rcv libjbig2enc.a jbig2enc.o jbig2arith.o jbig2sym.o +diff --git a/pdf.py b/pdf.py +index cd37c9f..4b4a8e8 100644 +--- a/pdf.py ++++ b/pdf.py +@@ -11,7 +11,7 @@ import os + # Run ./jbig2 -s -p <other options> image1.jpeg image1.jpeg ... + # python pdf.py output > out.pdf + +-dpi = 600 ++#dpi = 600 + + class Ref: +   def __init__(self, x): +@@ -121,16 +121,16 @@ def main(symboltable='symboltable', pagefiles=glob.glob('page-*')): +     except IOError: +       sys.stderr.write("error reading page file %s\n"% p) +       continue +-    (width, height) = struct.unpack('>II', contents[11:19]) ++    (width, height,xres,yres) = struct.unpack('>IIII', contents[11:27]) +     xobj = Obj({'Type': '/XObject', 'Subtype': '/Image', 'Width': +         str(width), 'Height': str(height), 'ColorSpace': '/DeviceGray', +         'BitsPerComponent': '1', 'Filter': '/JBIG2Decode', 'DecodeParms': +         ' << /JBIG2Globals %d 0 R >>' % symd.id}, contents) +-    contents = Obj({}, 'q %f 0 0 %f 0 0 cm /Im1 Do Q' % (float(width * 72) / dpi, float(height * 72) / dpi)) ++    contents = Obj({}, 'q %f 0 0 %f 0 0 cm /Im1 Do Q' % (float(width * 72) / xres, float(height * 72) / yres)) +     resources = Obj({'ProcSet': '[/PDF /ImageB]', +         'XObject': '<< /Im1 %d 0 R >>' % xobj.id}) +     page = Obj({'Type': '/Page', 'Parent': '3 0 R', +-        'MediaBox': '[ 0 0 %f %f ]' % (float(width * 72) / dpi, float(height * 72) / dpi), ++        'MediaBox': '[ 0 0 %f %f ]' % (float(width * 72) / xres, float(height * 72) / yres), +         'Contents': ref(contents.id), +         'Resources': ref(resources.id)}) +     [doc.add_object(x) for x in [xobj, contents, resources, page]]  | 
