texlive[41779] trunk: pdflatexpicscale (27jul16)
commits+karl at tug.org
commits+karl at tug.org
Sun Jul 31 01:20:03 CEST 2016
Revision: 41779
http://tug.org/svn/texlive?view=revision&revision=41779
Author: karl
Date: 2016-07-31 01:20:02 +0200 (Sun, 31 Jul 2016)
Log Message:
-----------
pdflatexpicscale (27jul16)
Modified Paths:
--------------
trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/libexec/ctan2tds
trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
Added Paths:
-----------
trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/
trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/pdflatexpicscale.pl
trunk/Master/bin/amd64-freebsd/pdflatexpicscale
trunk/Master/bin/amd64-netbsd/pdflatexpicscale
trunk/Master/bin/armel-linux/pdflatexpicscale
trunk/Master/bin/armhf-linux/pdflatexpicscale
trunk/Master/bin/i386-cygwin/pdflatexpicscale
trunk/Master/bin/i386-freebsd/pdflatexpicscale
trunk/Master/bin/i386-linux/pdflatexpicscale
trunk/Master/bin/i386-netbsd/pdflatexpicscale
trunk/Master/bin/i386-solaris/pdflatexpicscale
trunk/Master/bin/powerpc-linux/pdflatexpicscale
trunk/Master/bin/sparc-solaris/pdflatexpicscale
trunk/Master/bin/universal-darwin/pdflatexpicscale
trunk/Master/bin/win32/pdflatexpicscale.exe
trunk/Master/bin/x86_64-cygwin/pdflatexpicscale
trunk/Master/bin/x86_64-darwin/pdflatexpicscale
trunk/Master/bin/x86_64-linux/pdflatexpicscale
trunk/Master/bin/x86_64-solaris/pdflatexpicscale
trunk/Master/texmf-dist/doc/support/pdflatexpicscale/
trunk/Master/texmf-dist/doc/support/pdflatexpicscale/README
trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf
trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps
trunk/Master/texmf-dist/scripts/pdflatexpicscale/
trunk/Master/texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
trunk/Master/tlpkg/tlpsrc/pdflatexpicscale.tlpsrc
Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.am
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.am 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.am 2016-07-30 23:20:02 UTC (rev 41779)
@@ -152,6 +152,7 @@
oberdiek/pdfatfi.pl \
pax/pdfannotextractor.pl \
pdfcrop/pdfcrop.pl \
+ pdflatexpicscale/pdflatexpicscale.pl \
pedigree-perl/pedigree.pl \
perltex/perltex.pl \
petri-nets/pn2pdf \
Modified: trunk/Build/source/texk/texlive/linked_scripts/Makefile.in
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/Makefile.in 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Build/source/texk/texlive/linked_scripts/Makefile.in 2016-07-30 23:20:02 UTC (rev 41779)
@@ -367,6 +367,7 @@
oberdiek/pdfatfi.pl \
pax/pdfannotextractor.pl \
pdfcrop/pdfcrop.pl \
+ pdflatexpicscale/pdflatexpicscale.pl \
pedigree-perl/pedigree.pl \
perltex/perltex.pl \
petri-nets/pn2pdf \
Added: trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/pdflatexpicscale.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/pdflatexpicscale.pl (rev 0)
+++ trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/pdflatexpicscale.pl 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1,227 @@
+#!/usr/bin/perl -w
+# Scale pictures to be included into a LaTeX generated PDF file.
+# version 0.1 written by peter willadt
+# contact willadt at t-online.de
+# this software is subject to the LaTeX project public license.
+# changes:
+# 2016-08-01 first public release
+
+use strict;
+use File::Basename;
+use File::Spec;
+use File::Copy;
+use Getopt::Long;
+
+my $version = '0.1';
+my $versiondate = '2016-07-28';
+my $showversion;
+
+my $verbose;
+my $TeXproject;
+
+# folders for scaled graphics, relative names
+my $printfolderprefix = 'printimg';
+my $previewfolderprefix = 'previewimg';
+my $srcfolder = '';
+
+# final resolution. special b/w handling not implemented yet
+my $printdpi = 300;
+my $printbwdpi = 4 * $printdpi;
+my $previewdpi = 72;
+my $tolerance = 20;
+
+# file formats
+my %canhandle =
+( JPG => '1',
+ PNG => '1',
+);
+
+# bookkeeping
+my %processedimages;
+my $copied = 0;
+my $scaled = 0;
+my $skipped = 0;
+
+sub printInplaceError
+{
+ my $filename = shift;
+ print "I will not do inplace modification of graphics:\n" .
+ "($filename) will not be processed. (Missing path?)\n";
+}
+
+sub printMissingError
+{
+ my $filename = shift;
+ print "I can not find ($filename). (What have you done?)\n";
+}
+
+sub handleImage
+{
+ my $filename = shift;
+ my $dstwidth = shift;
+ my $dstheight = shift;
+ my ($srcwidth, $srcheight, $srcdepth);
+ my $dstfilename;
+ my $xfilename;
+ my @xsrcdirs;
+ my @dstdirs;
+ my @convertargs;
+ my $idstring;
+
+ $dstdirs[0] = '.';
+ $dstdirs[1] = $printfolderprefix;
+ $dstfilename = File::Spec->catfile(@dstdirs, basename($filename));
+ if($filename eq $dstfilename){
+ unless ($srcfolder > ' ') {
+ printInplaceError($filename);
+ $skipped++;
+ return;
+ }
+ $xsrcdirs[0] = $srcfolder;
+ $xfilename = File::Spec->catfile(@xsrcdirs, basename($filename));
+ unless (-e $xfilename){
+ printMissingError($xfilename);
+ $skipped++;
+ return;
+ }
+ $filename = $xfilename;
+ }
+ # check for image width and height
+ $idstring = `identify -format "%w x %h %[depth] " $filename`;
+ return unless $idstring =~ /(\d+) x (\d+) (\d+)/;
+ $srcwidth = $1; $srcheight = $2; $srcdepth = $3;
+ if($srcdepth == 1) { # hires for bw pix
+ $dstwidth = int($dstwidth * $printbwdpi / 72.27 + .5);
+ $dstheight = int($dstheight * $printbwdpi / 72.27 + .5);
+ }else { # moderate res for any other
+ $dstwidth = int($dstwidth * $printdpi / 72.27 + .5);
+ $dstheight = int($dstheight * $printdpi / 72.27 + .5);
+ }
+ if(-e $dstfilename){
+ # if younger and requested size: skip
+ my ($mtime1, $mtime2, $size1, $size2, $idstring2, $existwidth);
+ my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $ctime, $blksize, $blocks);
+ ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $mtime1, $ctime, $blksize, $blocks)
+ = stat($dstfilename);
+ ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $mtime2, $ctime, $blksize, $blocks)
+ = stat($filename);
+ if($mtime1 >= $mtime2){
+ $idstring2 = `identify -format "%w x %h %[depth] " $dstfilename`;
+ if($idstring2 =~ /(\d+) x (\d+) (\d+)/){
+ $existwidth = $1;
+ if($existwidth == $dstwidth){
+ $processedimages{$filename} = $existwidth;
+ $skipped++;
+ return;
+ }
+ }
+ }
+ }
+ if(($dstwidth >= $srcwidth) ||
+ ($dstwidth *(100 + $tolerance)/100 >= $srcwidth)) {
+ # we do no upscaling, but will probably copy the file.
+ if (defined $processedimages{$filename}){
+ $skipped++;
+ }else {
+ $processedimages{$filename} = $srcwidth;
+ print "will copy $filename to $dstfilename\n" if $verbose;
+ copy($filename, $dstfilename);
+ $copied++;
+ return;
+ }
+ }else {
+ if((defined $processedimages{$filename}) &&
+ ($processedimages{$filename} >= $dstwidth)) {
+ $skipped++;
+ return;
+ }
+ # we do some downscaling
+ $processedimages{$filename} = $dstwidth;
+ $convertargs[0] = 'convert';
+ $convertargs[1] = ${filename};
+ $convertargs[2] = '-resize';
+# $convertargs[3] = "${dstwidth}x${dstheight}!";
+ $convertargs[3] = "${dstwidth}x${dstheight}";
+ $convertargs[4] = "-density";
+ $convertargs[5] = $printdpi;
+ $convertargs[6] = ${dstfilename};
+ print "will @convertargs\n" if $verbose;
+ system(@convertargs);
+ $scaled++;
+ }
+}
+
+sub readlog
+{
+ my $logfilename = shift;
+ $logfilename .= '.log';
+ my ($picname, $picext, $picwidth, $picheight);
+ my ($picextu, $needsize);
+ open LOGFILE, "<$logfilename" or die "Cannot read $logfilename";
+ $needsize = 0;
+ while (<LOGFILE>){
+ if (/^Package pdftex\.def Info\: (\S*)\.(\w+) used /){
+ $picname = $1;
+ $picext = $2;
+ ($picextu = $picext) =~ tr/a-z/A-Z/;
+ if( defined $canhandle{$picextu}){
+ $needsize = 1;
+ next;
+ }
+ }
+ next unless ($needsize == 1);
+ next unless /Requested size: (\d+\.\d+)pt x (\d+\.\d+)pt/;
+ $picwidth = $1;
+ $picheight = $2;
+ handleImage("$picname.$picext", $picwidth, $picheight);
+ $needsize = 0;
+ }
+}
+
+sub usage
+{
+ print <<'_endusage';
+pdflatexpicscale will downscale large raster images for your TeX project
+to reasonable size.
+Basic usage:
+ pdflatexpicscale myarticle
+where your main LaTeX file is called 'myarticle.tex' and a log file exists.
+Fine tuning:
+--destdir=folder (relative path, must exist,
+ defaults to 'printimg' subfolder of current folder)
+--srcdir=folder (folder to find original images, if this software
+ can't figure it out on it's own, because you already
+ used the target directory.)
+--printdpi=XXX (default 300)
+--tolerance=XX (default 20 Percents over printdpi to ignore scaling)
+--verbose (if you want to know what the script attempts to do)
+--version (show software version)
+_endusage
+}
+
+GetOptions('verbose' => \$verbose,
+ 'printdpi=i' => \$printdpi,
+ 'destdir=s' => \$printfolderprefix,
+ 'tolerance=i' => \$tolerance,
+ 'srcdir=s' => \$srcfolder,
+ 'version' => \$showversion);
+
+$TeXproject = shift;
+
+if($showversion){
+ print "pdflatexpicscale Version $version $versiondate\n";
+}
+
+unless ($TeXproject gt ' '){
+ usage();
+ end();
+}
+
+readlog($TeXproject);
+if($verbose) {
+ print "$copied file(s) copied, $scaled file(s) converted " .
+ "and $skipped occurence(s) skipped.\n";
+}
Property changes on: trunk/Build/source/texk/texlive/linked_scripts/pdflatexpicscale/pdflatexpicscale.pl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/Build/source/texk/texlive/linked_scripts/scripts.lst
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/scripts.lst 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Build/source/texk/texlive/linked_scripts/scripts.lst 2016-07-30 23:20:02 UTC (rev 41779)
@@ -97,6 +97,7 @@
oberdiek/pdfatfi.pl
pax/pdfannotextractor.pl
pdfcrop/pdfcrop.pl
+pdflatexpicscale/pdflatexpicscale.pl
pedigree-perl/pedigree.pl
perltex/perltex.pl
petri-nets/pn2pdf
Added: trunk/Master/bin/amd64-freebsd/pdflatexpicscale
===================================================================
--- trunk/Master/bin/amd64-freebsd/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/amd64-freebsd/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/amd64-freebsd/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/amd64-netbsd/pdflatexpicscale
===================================================================
--- trunk/Master/bin/amd64-netbsd/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/amd64-netbsd/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/amd64-netbsd/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/armel-linux/pdflatexpicscale
===================================================================
--- trunk/Master/bin/armel-linux/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/armel-linux/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/armel-linux/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/armhf-linux/pdflatexpicscale
===================================================================
--- trunk/Master/bin/armhf-linux/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/armhf-linux/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/armhf-linux/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-cygwin/pdflatexpicscale
===================================================================
--- trunk/Master/bin/i386-cygwin/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/i386-cygwin/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/i386-cygwin/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-freebsd/pdflatexpicscale
===================================================================
--- trunk/Master/bin/i386-freebsd/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/i386-freebsd/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/i386-freebsd/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-linux/pdflatexpicscale
===================================================================
--- trunk/Master/bin/i386-linux/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/i386-linux/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/i386-linux/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-netbsd/pdflatexpicscale
===================================================================
--- trunk/Master/bin/i386-netbsd/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/i386-netbsd/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/i386-netbsd/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/i386-solaris/pdflatexpicscale
===================================================================
--- trunk/Master/bin/i386-solaris/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/i386-solaris/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/i386-solaris/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/powerpc-linux/pdflatexpicscale
===================================================================
--- trunk/Master/bin/powerpc-linux/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/powerpc-linux/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/powerpc-linux/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/sparc-solaris/pdflatexpicscale
===================================================================
--- trunk/Master/bin/sparc-solaris/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/sparc-solaris/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/sparc-solaris/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/universal-darwin/pdflatexpicscale
===================================================================
--- trunk/Master/bin/universal-darwin/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/universal-darwin/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/universal-darwin/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/win32/pdflatexpicscale.exe
===================================================================
(Binary files differ)
Index: trunk/Master/bin/win32/pdflatexpicscale.exe
===================================================================
--- trunk/Master/bin/win32/pdflatexpicscale.exe 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/bin/win32/pdflatexpicscale.exe 2016-07-30 23:20:02 UTC (rev 41779)
Property changes on: trunk/Master/bin/win32/pdflatexpicscale.exe
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/bin/x86_64-cygwin/pdflatexpicscale
===================================================================
--- trunk/Master/bin/x86_64-cygwin/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/x86_64-cygwin/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/x86_64-cygwin/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-darwin/pdflatexpicscale
===================================================================
--- trunk/Master/bin/x86_64-darwin/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/x86_64-darwin/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/x86_64-darwin/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-linux/pdflatexpicscale
===================================================================
--- trunk/Master/bin/x86_64-linux/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/x86_64-linux/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/x86_64-linux/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/bin/x86_64-solaris/pdflatexpicscale
===================================================================
--- trunk/Master/bin/x86_64-solaris/pdflatexpicscale (rev 0)
+++ trunk/Master/bin/x86_64-solaris/pdflatexpicscale 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+link ../../texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
\ No newline at end of file
Property changes on: trunk/Master/bin/x86_64-solaris/pdflatexpicscale
___________________________________________________________________
Added: svn:special
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdflatexpicscale/README (rev 0)
+++ trunk/Master/texmf-dist/doc/support/pdflatexpicscale/README 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1,30 @@
+pdflatexpicscale is software to scale pictures down
+to a target resolution before creating a PDF document
+with PdfLaTeX.
+
+*Requirements*
+Perl and ImageMagick have to be installed.
+
+*Basic usage*
+pdflatex article
+pdflatexpicscale.pl article
+edit article.tex: insert \graphicspath{{printimg/}}
+pdflatex article
+and you're done.
+
+For more information, please consult pdflatexpicscale.pdf.
+
+*File list*
+README This file
+pdflatexpicscale.pl Tool, perl code
+pdflatexpicscale.pdf Documentation (Installation and usage)
+testprinter.ps Resolution test file for your PostScript printer
+
+*Licensing*
+pdflatexpicscale and the accompanying files are
+subject to the current version of the
+LaTeX project public license (not included).
+
+*Author*
+Peter Willadt
+Email: willadt at t-online.de
Property changes on: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/README
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf 2016-07-30 23:20:02 UTC (rev 41779)
Property changes on: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/pdflatexpicscale.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps 2016-07-30 23:20:02 UTC (rev 41779)
Property changes on: trunk/Master/texmf-dist/doc/support/pdflatexpicscale/testprinter.ps
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/postscript
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl (rev 0)
+++ trunk/Master/texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1,227 @@
+#!/usr/bin/perl -w
+# Scale pictures to be included into a LaTeX generated PDF file.
+# version 0.1 written by peter willadt
+# contact willadt at t-online.de
+# this software is subject to the LaTeX project public license.
+# changes:
+# 2016-08-01 first public release
+
+use strict;
+use File::Basename;
+use File::Spec;
+use File::Copy;
+use Getopt::Long;
+
+my $version = '0.1';
+my $versiondate = '2016-07-28';
+my $showversion;
+
+my $verbose;
+my $TeXproject;
+
+# folders for scaled graphics, relative names
+my $printfolderprefix = 'printimg';
+my $previewfolderprefix = 'previewimg';
+my $srcfolder = '';
+
+# final resolution. special b/w handling not implemented yet
+my $printdpi = 300;
+my $printbwdpi = 4 * $printdpi;
+my $previewdpi = 72;
+my $tolerance = 20;
+
+# file formats
+my %canhandle =
+( JPG => '1',
+ PNG => '1',
+);
+
+# bookkeeping
+my %processedimages;
+my $copied = 0;
+my $scaled = 0;
+my $skipped = 0;
+
+sub printInplaceError
+{
+ my $filename = shift;
+ print "I will not do inplace modification of graphics:\n" .
+ "($filename) will not be processed. (Missing path?)\n";
+}
+
+sub printMissingError
+{
+ my $filename = shift;
+ print "I can not find ($filename). (What have you done?)\n";
+}
+
+sub handleImage
+{
+ my $filename = shift;
+ my $dstwidth = shift;
+ my $dstheight = shift;
+ my ($srcwidth, $srcheight, $srcdepth);
+ my $dstfilename;
+ my $xfilename;
+ my @xsrcdirs;
+ my @dstdirs;
+ my @convertargs;
+ my $idstring;
+
+ $dstdirs[0] = '.';
+ $dstdirs[1] = $printfolderprefix;
+ $dstfilename = File::Spec->catfile(@dstdirs, basename($filename));
+ if($filename eq $dstfilename){
+ unless ($srcfolder > ' ') {
+ printInplaceError($filename);
+ $skipped++;
+ return;
+ }
+ $xsrcdirs[0] = $srcfolder;
+ $xfilename = File::Spec->catfile(@xsrcdirs, basename($filename));
+ unless (-e $xfilename){
+ printMissingError($xfilename);
+ $skipped++;
+ return;
+ }
+ $filename = $xfilename;
+ }
+ # check for image width and height
+ $idstring = `identify -format "%w x %h %[depth] " $filename`;
+ return unless $idstring =~ /(\d+) x (\d+) (\d+)/;
+ $srcwidth = $1; $srcheight = $2; $srcdepth = $3;
+ if($srcdepth == 1) { # hires for bw pix
+ $dstwidth = int($dstwidth * $printbwdpi / 72.27 + .5);
+ $dstheight = int($dstheight * $printbwdpi / 72.27 + .5);
+ }else { # moderate res for any other
+ $dstwidth = int($dstwidth * $printdpi / 72.27 + .5);
+ $dstheight = int($dstheight * $printdpi / 72.27 + .5);
+ }
+ if(-e $dstfilename){
+ # if younger and requested size: skip
+ my ($mtime1, $mtime2, $size1, $size2, $idstring2, $existwidth);
+ my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $ctime, $blksize, $blocks);
+ ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $mtime1, $ctime, $blksize, $blocks)
+ = stat($dstfilename);
+ ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
+ $atime, $mtime2, $ctime, $blksize, $blocks)
+ = stat($filename);
+ if($mtime1 >= $mtime2){
+ $idstring2 = `identify -format "%w x %h %[depth] " $dstfilename`;
+ if($idstring2 =~ /(\d+) x (\d+) (\d+)/){
+ $existwidth = $1;
+ if($existwidth == $dstwidth){
+ $processedimages{$filename} = $existwidth;
+ $skipped++;
+ return;
+ }
+ }
+ }
+ }
+ if(($dstwidth >= $srcwidth) ||
+ ($dstwidth *(100 + $tolerance)/100 >= $srcwidth)) {
+ # we do no upscaling, but will probably copy the file.
+ if (defined $processedimages{$filename}){
+ $skipped++;
+ }else {
+ $processedimages{$filename} = $srcwidth;
+ print "will copy $filename to $dstfilename\n" if $verbose;
+ copy($filename, $dstfilename);
+ $copied++;
+ return;
+ }
+ }else {
+ if((defined $processedimages{$filename}) &&
+ ($processedimages{$filename} >= $dstwidth)) {
+ $skipped++;
+ return;
+ }
+ # we do some downscaling
+ $processedimages{$filename} = $dstwidth;
+ $convertargs[0] = 'convert';
+ $convertargs[1] = ${filename};
+ $convertargs[2] = '-resize';
+# $convertargs[3] = "${dstwidth}x${dstheight}!";
+ $convertargs[3] = "${dstwidth}x${dstheight}";
+ $convertargs[4] = "-density";
+ $convertargs[5] = $printdpi;
+ $convertargs[6] = ${dstfilename};
+ print "will @convertargs\n" if $verbose;
+ system(@convertargs);
+ $scaled++;
+ }
+}
+
+sub readlog
+{
+ my $logfilename = shift;
+ $logfilename .= '.log';
+ my ($picname, $picext, $picwidth, $picheight);
+ my ($picextu, $needsize);
+ open LOGFILE, "<$logfilename" or die "Cannot read $logfilename";
+ $needsize = 0;
+ while (<LOGFILE>){
+ if (/^Package pdftex\.def Info\: (\S*)\.(\w+) used /){
+ $picname = $1;
+ $picext = $2;
+ ($picextu = $picext) =~ tr/a-z/A-Z/;
+ if( defined $canhandle{$picextu}){
+ $needsize = 1;
+ next;
+ }
+ }
+ next unless ($needsize == 1);
+ next unless /Requested size: (\d+\.\d+)pt x (\d+\.\d+)pt/;
+ $picwidth = $1;
+ $picheight = $2;
+ handleImage("$picname.$picext", $picwidth, $picheight);
+ $needsize = 0;
+ }
+}
+
+sub usage
+{
+ print <<'_endusage';
+pdflatexpicscale will downscale large raster images for your TeX project
+to reasonable size.
+Basic usage:
+ pdflatexpicscale myarticle
+where your main LaTeX file is called 'myarticle.tex' and a log file exists.
+Fine tuning:
+--destdir=folder (relative path, must exist,
+ defaults to 'printimg' subfolder of current folder)
+--srcdir=folder (folder to find original images, if this software
+ can't figure it out on it's own, because you already
+ used the target directory.)
+--printdpi=XXX (default 300)
+--tolerance=XX (default 20 Percents over printdpi to ignore scaling)
+--verbose (if you want to know what the script attempts to do)
+--version (show software version)
+_endusage
+}
+
+GetOptions('verbose' => \$verbose,
+ 'printdpi=i' => \$printdpi,
+ 'destdir=s' => \$printfolderprefix,
+ 'tolerance=i' => \$tolerance,
+ 'srcdir=s' => \$srcfolder,
+ 'version' => \$showversion);
+
+$TeXproject = shift;
+
+if($showversion){
+ print "pdflatexpicscale Version $version $versiondate\n";
+}
+
+unless ($TeXproject gt ' '){
+ usage();
+ end();
+}
+
+readlog($TeXproject);
+if($verbose) {
+ print "$copied file(s) copied, $scaled file(s) converted " .
+ "and $skipped occurence(s) skipped.\n";
+}
Property changes on: trunk/Master/texmf-dist/scripts/pdflatexpicscale/pdflatexpicscale.pl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2016-07-30 23:20:02 UTC (rev 41779)
@@ -440,7 +440,8 @@
patch patchcmd patgen2-tutorial path pauldoc pawpict pax
pbibtex-base pbox pb-diagram pbsheet
pdf14
- pdf-trans pdfbook2 pdfcomment pdfcprot pdfcrop pdfjam pdfmarginpar
+ pdf-trans pdfbook2 pdfcomment pdfcprot pdfcrop pdfjam
+ pdflatexpicscale pdfmarginpar
pdfpagediff pdfpages pdfscreen pdfslide pdfsync
pdftricks pdftricks2 pdfx pdfxup
pecha pedigree-perl perception perfectcut perltex
Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/tlpkg/libexec/ctan2tds 2016-07-30 23:20:02 UTC (rev 41779)
@@ -2757,6 +2757,7 @@
'pdfbook2' => 'pdfbook2$',
'pdfcrop' => '\.pl$', # doscripts() does r*
'pdfjam' => 'pdf[^.]*$',
+ 'pdflatexpicscale' => '\.pl$',
'pdfxup' => 'pdfxup$',
'pedigree-perl' => '\.pl$',
'perltex' => '\.pl$',
@@ -5514,12 +5515,20 @@
# (but not for mptopdf, since peb unified it.)
return if $exec =~ /mptopdf/;
(my $exec_basename = $exec) =~ s,^.*/,,;
+ my $pattern = "\\b$build_subdir/$exec_basename\\b";
+ #
my $scripts_Makefile = "$Build/$build_scriptsdir/Makefile.in";
- my $pattern = "\\b$build_subdir/$exec_basename\\b";
system ("grep '$pattern' $scripts_Makefile >/dev/null");
if ($? != 0) {
print "*** $build_subdir/$exec_basename not in $scripts_Makefile\n";
}
+ # we'd should get rid of scripts.lst since it is nothing but
+ # redundancy; coordinate with debian, though.
+ my $scripts_lst = "$Build/$build_scriptsdir/scripts.lst";
+ system ("grep '$pattern' $scripts_lst >/dev/null");
+ if ($? != 0) {
+ print "*** $build_subdir/$exec_basename not in $scripts_lst\n";
+ }
}
sub POSTcontext_games {
Modified: trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc 2016-07-30 23:13:20 UTC (rev 41778)
+++ trunk/Master/tlpkg/tlpsrc/collection-binextra.tlpsrc 2016-07-30 23:20:02 UTC (rev 41779)
@@ -56,6 +56,7 @@
depend pdfbook2
depend pdfcrop
depend pdfjam
+depend pdflatexpicscale
depend pdftools
depend pdfxup
depend pfarrei
Added: trunk/Master/tlpkg/tlpsrc/pdflatexpicscale.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/pdflatexpicscale.tlpsrc (rev 0)
+++ trunk/Master/tlpkg/tlpsrc/pdflatexpicscale.tlpsrc 2016-07-30 23:20:02 UTC (rev 41779)
@@ -0,0 +1 @@
+binpattern f bin/${ARCH}/${PKGNAME}
More information about the tex-live-commits
mailing list