mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[pngzop] Added picksmaller script, added license info.
This commit is contained in:
27
picksmaller
Executable file
27
picksmaller
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# For use in the pngzop project
|
||||
# Copyright 2013 by Glenn Randers-Pehrson
|
||||
# Released under the pngcrush license (equivalent to the libpng license)
|
||||
|
||||
# Selects the smaller of file.zdat (extracted from a PNG) or
|
||||
# file.idat.zlib (same but recompressed with zopfli)
|
||||
|
||||
# picksmall file1 file2
|
||||
|
||||
for file in $*
|
||||
do
|
||||
file1=$1
|
||||
file2=`echo $file1 | sed -e "s/zdat/idat.zlib/"`
|
||||
shift
|
||||
|
||||
size1=`ls -l $file1 | sed -e "s/[^ ]* [^ ]* [^ ]* [^ ]* //" -e "s/ .*//"`
|
||||
size2=`ls -l $file2 | sed -e "s/[^ ]* [^ ]* [^ ]* [^ ]* //" -e "s/ .*//"`
|
||||
|
||||
if [ $size1 -le $size2 ] ; then
|
||||
echo $file1
|
||||
else
|
||||
echo $file2
|
||||
fi
|
||||
|
||||
done
|
||||
7
pngidat
7
pngidat
@@ -1,5 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# For use in the pngzop project
|
||||
# Copyright 2013 by Glenn Randers-Pehrson
|
||||
# Released under the pngcrush license (equivalent to the libpng license)
|
||||
|
||||
# Extracts and decompresses the data from the IDAT chunks in a set of
|
||||
# PNG files.
|
||||
|
||||
for x in $*
|
||||
do
|
||||
root=`echo $1 | sed -e s/.png$//`
|
||||
|
||||
27
pngidat.c
27
pngidat.c
@@ -1,18 +1,21 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/* Copyright 2013 Glenn Randers-Pehrson */
|
||||
/* Copyright 2013 Glenn Randers-Pehrson
|
||||
* Released under the pngcrush license (equivalent to the libpng license)
|
||||
*/
|
||||
|
||||
/* Usage:
|
||||
* pngidat.exe < file.png | pigz -d > file.idat
|
||||
* pngidat.exe < file.png > file.zdat
|
||||
*
|
||||
* file.idat is the zlib datastream from the PNG IDAT chunks.
|
||||
*
|
||||
* file.idat is the image datastream, with the filter bytes.
|
||||
*/
|
||||
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
int buf[5];
|
||||
int c;
|
||||
unsigned int i;
|
||||
unsigned int buf[5];
|
||||
unsigned int c;
|
||||
|
||||
buf[4]='\0';
|
||||
|
||||
@@ -23,7 +26,7 @@ main()
|
||||
for (;;)
|
||||
{
|
||||
/* read length */
|
||||
int length;
|
||||
unsigned int length;
|
||||
buf[0]=getchar();
|
||||
if (buf[0] == EOF)
|
||||
break;
|
||||
@@ -46,7 +49,9 @@ for (;;)
|
||||
break;
|
||||
putchar(c);
|
||||
}
|
||||
/* skip crc byte */
|
||||
if (c == EOF)
|
||||
break;
|
||||
/* skip crc bytes */
|
||||
for (i=4; i; i--)
|
||||
{
|
||||
c=getchar();
|
||||
@@ -59,7 +64,13 @@ for (;;)
|
||||
else
|
||||
{
|
||||
for (i=length+4; i; i--)
|
||||
{
|
||||
c=getchar();
|
||||
if (c == EOF)
|
||||
break;
|
||||
}
|
||||
if (c == EOF)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
pngzdat
6
pngzdat
@@ -1,5 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# For use in the pngzop project
|
||||
# Copyright 2013 by Glenn Randers-Pehrson
|
||||
# Released under the pngcrush license (equivalent to the libpng license)
|
||||
|
||||
# Extracts the data from the IDAT chunks in a set of # PNG files.
|
||||
|
||||
for x in $*
|
||||
do
|
||||
root=`echo $1 | sed -e s/.png$//`
|
||||
|
||||
Reference in New Issue
Block a user