- sync to 2.0.3

master
pierre 2006-04-05 15:43:50 +00:00
parent eb35b4e29e
commit 9403f3ad12
5 changed files with 254 additions and 35 deletions

153
src/annotate.c Normal file
View File

@ -0,0 +1,153 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gd.h"
/* A neat little utility which adds freetype text to
existing JPEG images. Type annotate -h for instructions.
Thanks to Joel Dubiner for supporting this work. -TBB */
enum {
left, center, right
};
int main(int argc, char *argv[])
{
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
char s[1024];
int bounds[8];
int lines = 1;
int color = gdTrueColor(0, 0, 0);
char font[1024];
int size = 12;
int align = left;
int x = 0, y = 0;
char *fontError;
strcpy(font, "times");
if (argc != 3) {
fprintf(stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
fprintf(stderr, "Standard input should consist of\n");
fprintf(stderr, "lines in the following formats:\n");
fprintf(stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
fprintf(stderr, "font fontname\n");
fprintf(stderr, "size pointsize\n");
fprintf(stderr, "align (left|right|center)\n");
fprintf(stderr, "move x y\n");
fprintf(stderr, "text actual-output-text\n\n");
fprintf(stderr, "If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
fprintf(stderr, "location specified in the GDFONTPATH environment variable, 'font paris' is\n");
fprintf(stderr, "sufficient. You may also specify the full, rooted path of a font file.\n");
exit(1);
}
iin = argv[1];
iout = argv[2];
in = fopen(iin, "rb");
if (!in) {
fprintf(stderr, "Couldn't open %s\n", iin);
exit(2);
}
im = gdImageCreateFromJpeg(in);
fclose(in);
if (!im) {
fprintf(stderr, "%s did not load properly\n", iin);
exit(3);
}
while (fgets(s, sizeof(s), stdin)) {
char *st;
char *text;
st = strtok(s, " \t\r\n");
if (!st) {
/* Be nice about blank lines */
continue;
}
if (!strcmp(st, "font")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
strcpy(font, st);
} else if (!strcmp(st, "align")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
if (!strcmp(st, "left")) {
align = 0;
} else if (!strcmp(st, "center")) {
align = 1;
} else if (!strcmp(st, "right")) {
align = 2;
}
} else if (!strcmp(st, "size")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
size = atoi(st);
} else if (!strcmp(st, "color")) {
char *st = strtok(0, "\r\n");
int r, g, b, a = 0;
if (!st) {
goto badLine;
}
if (sscanf(st, "%d %d %d %d", &r, &g, &b, &a) < 3) {
fprintf(stderr, "Bad color at line %d\n", lines);
exit(2);
}
color = gdTrueColorAlpha(r, g, b, a);
} else if (!strcmp(st, "move")) {
char *st = strtok(0, "\r\n");
if (!st) {
goto badLine;
}
if (sscanf(st, "%d %d", &x, &y) != 2) {
fprintf(stderr, "Missing coordinates at line %d\n", lines);
exit(3);
}
} else if (!strcmp(st, "text")) {
int rx = x;
text = strtok(0, "\r\n");
if (!text) {
text = "";
}
gdImageStringFT(0, bounds, color, font,
size, 0, x, y, text);
switch (align) {
case left:
break;
case center:
rx -= (bounds[2] - bounds[0]) / 2;
break;
case right:
rx -= (bounds[2] - bounds[0]);
break;
}
fontError = gdImageStringFT(im, 0, color, font,
size, 0, rx, y, text);
if (fontError) {
fprintf(stderr, "font error at line %d: %s\n", lines, fontError);
exit(7);
}
y -= (bounds[7] - bounds[1]);
} else {
goto badLine;
}
lines++;
continue;
badLine:
fprintf(stderr, "Bad syntax, line %d\n", lines);
exit(4);
}
out = fopen(iout, "wb");
if (!out) {
fprintf(stderr, "Cannot create %s\n", iout);
exit(5);
}
gdImageJpeg(im, out, 95);
gdImageDestroy(im);
fclose(out);
return 0;
}

88
src/configure vendored
View File

@ -28,7 +28,7 @@ $installPrefix = "/usr";
#accommodated; surprisingly, I am not perfect)
for ($i = 0; ($i < int(@ARGV)); $i++) {
if ($a eq "--prefix") {
if ($ARGV[$i] eq "--prefix") {
if ($ARGV[$i + 1] eq "") {
die "No directory specified for --prefix\n";
} else {
@ -51,12 +51,12 @@ if (!&testCompiler) {
#If we don't know, we try the elegant Linux way
if ($os =~ /^(linux|irix|tru64|ultrix|openbsd|netbsd)/i) {
if ($os =~ /^(linux|irix|tru64|ultrix|openbsd|netbsd|freebsd)/i) {
$sharedLinkHead = "ld -shared";
$sharedLinkTail = "";
print "Found OS with linux-like shared library link command\n";
} elsif ($os =~ /^(sunos)/i) {
$sharedLinkHead = "ld -G";
$sharedLinkHead = "/usr/ccs/bin/ld -G";
$sharedLinkTail = "-ldl";
print "Found OS with sunos-like shared library link command\n";
} elsif ($os =~ /^(darwin)/i) {
@ -73,10 +73,18 @@ print "Shared library link command: $sharedLinkHead $sharedLinkTail\n";
if (&testLibrary("png", "png_create_read_struct (0, 0, 0, 0)", "-lz")) {
push @options, "png";
push @options, "z";
print "png library found.\n";
} else {
print "Warning: png and/or zlib library not found, png will not be supported.\n";
print "Warning: png library not found, png will not be supported.\n";
}
if (&testLibrary("z", "deflate (0, 0)")) {
push @options, "z";
print "zlib library found.\n";
$zfound = 1;
} else {
print "Warning: zlib library not found, png (which you might want a lot) and\n",
"gd2 (which you probably don't need) will not be supported.\n";
}
if (&testLibrary("jpeg", "jpeg_set_defaults (0)")) {
@ -100,6 +108,28 @@ if (&testLibrary("xpm", "XpmReadFileToXpmImage(0, 0, 0)")) {
print "xpm library not found. That's OK. Almost no one needs xpm in gd.\n";
}
for $o (@options) {
$options{$o} = 1;
}
if (!int(@options)) {
print <<EOM
*******************************************************************
WARNING: NONE of the libraries needed to produce popular image
formats were found. This is not a good thing. The library can
be compiled, but it will not be able to produce PNG or JPEG
or XPM images. Only a few minor formats can be supported without
libraries. "make test" will not succeed without libraries; this
is to be expected. IF YOU ARE NOT SURE THIS IS OK, you should go
get libpng, libjpeg and libz now, and install them. Then run
configure again.
*******************************************************************
EOM
;
}
print "Optional libraries found: @options\n";
for $o (@options) {
@ -107,6 +137,19 @@ for $o (@options) {
$lflags .= " -l$o";
}
if ($options{"png"}) {
$safePrograms = "pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng";
}
if ($options{"freetype"} && $options{"jpeg"}) {
$safePrograms .= " annotate";
}
@programs = split(/ /, $safePrograms);
for $p (@programs) {
$installCommands .= "\tsh ./install-item 755 $p \$(INSTALL_BIN)/$p\n";
}
open(OUT, ">Makefile");
print OUT <<EOM
@ -142,16 +185,15 @@ INSTALL_BIN=$installPrefix/bin
# Update these with each release!
MAJOR_VERSION=2
VERSION=2.0.2
VERSION=2.0.3
COMPILER=$compiler
CC=\$(COMPILER) \$(INCLUDEDIRS)
LINK=\$(CC) \$(LIBDIRS) \$(LIBS)
PROGRAMS=\$(BIN_PROGRAMS) \$(TEST_PROGRAMS)
PROGRAMS=$safePrograms \$(TEST_PROGRAMS)
BIN_PROGRAMS=pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
TEST_PROGRAMS=gdtest gddemo gd2time gdtestft testac
default: instructions
@ -177,15 +219,8 @@ instructions:
test: \$(TEST_PROGRAMS)
install: libgd.so.\${VERSION} \$(BIN_PROGRAMS)
sh ./install-item 755 pngtogd \$(INSTALL_BIN)/pngtogd
sh ./install-item 755 pngtogd2 \$(INSTALL_BIN)/pngtogd2
sh ./install-item 755 gdtopng \$(INSTALL_BIN)/gdtopng
sh ./install-item 755 gd2topng \$(INSTALL_BIN)/gd2topng
sh ./install-item 755 gd2copypal \$(INSTALL_BIN)/gd2copypal
sh ./install-item 755 gdparttopng \$(INSTALL_BIN)/gdparttopng
sh ./install-item 755 webpng \$(INSTALL_BIN)/webpng
sh ./install-item 755 bdftogd \$(INSTALL_BIN)/bdftogd
install: libgd.so.\${VERSION} $safePrograms
$installCommands sh ./install-item 755 bdftogd \$(INSTALL_BIN)/bdftogd
sh ./install-item 644 gd.h \$(INSTALL_INCLUDE)/gd.h
sh ./install-item 644 gdcache.h \$(INSTALL_INCLUDE)/gdcache.h
sh ./install-item 644 gd_io.h \$(INSTALL_INCLUDE)/gd_io.h
@ -207,6 +242,9 @@ pngtogd: pngtogd.o
webpng: webpng.o
\$(CC) webpng.o -o webpng \$(LIBDIRS) \$(LIBS)
annotate: annotate.o
\$(CC) annotate.o -o annotate \$(LIBDIRS) \$(LIBS)
pngtogd2: pngtogd2.o
\$(CC) pngtogd2.o -o pngtogd2 \$(LIBDIRS) \$(LIBS)
@ -261,7 +299,9 @@ libgd.a: \${LIBOBJS}
-ranlib libgd.a
clean:
rm -f *.o *.a *.so *.so.* \${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp test/fttest.png test/fttest.jpg
rm -f *.o *.a *.so *.so.* \${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp test/fttest.png test/fttest.jpg *test.errors
veryclean: clean
rm Makefile
EOM
;
@ -292,7 +332,12 @@ int main(int argc, char *argv[])
}
EOM
;
my($result) = system("cd $ltest; $compiler libtest.c -o libtest -l$library $reqLibraries >& ../libtest.errors");
# 2.03: have to close!
close(OUT);
# 2.03: make sure we pass the math library, many
# platforms require it separately
# 2.03: >& is a bash-ism, can't rely on it
my($result) = system("cd $ltest; $compiler libtest.c -o libtest $libDirs -l$library -lm $reqLibraries > ../libtest.errors 2>&1");
system("rm -rf $ltest");
if ($result != 0) {
return 0;
@ -316,7 +361,10 @@ int main(int argc, char *argv[])
}
EOM
;
my($result) = system("cd $ctest; $compiler compilertest.c -o compilertest >& ../compilertest.errors");
# 2.03: have to close!
close(OUT);
# 2.03: correct for all sh, not just bash
my($result) = system("cd $ctest; $compiler compilertest.c -o compilertest > ../compilertest.errors 2>&1");
system("rm -rf $ctest");
if ($result != 0) {
return 0;

View File

@ -2,7 +2,7 @@
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <zlib.h>
/* 2.03: don't include zlib here or we can't build without PNG */
#include "gd.h"
#include "gdhelpers.h"

View File

@ -10,6 +10,9 @@
*
*/
/* 2.03: gd2 is no longer mandatory */
#ifdef HAVE_LIBZ
#include <stdio.h>
#include <errno.h>
#include <math.h>
@ -921,3 +924,6 @@ gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
out->free (out);
return rv;
}
#endif /* HAVE_LIBZ */

View File

@ -1,19 +1,19 @@
<HTML>
<HEAD>
<TITLE>gd 2.0.2</TITLE>
<TITLE>gd 2.0.3</TITLE>
</HEAD>
<BODY>
<!-- BANNER HERE -->
<h1>This is gd 2.0.2.</h1>
<h1>This is gd 2.0.3.</h1>
<p>
<H2>gd 2.0.2</H2>
<H2>gd 2.0.3</H2>
<H3>A graphics library for fast image creation</H3>
<H3>Follow this link to the
<A HREF="http://www.boutell.com/gd/">latest version
of this document</A>.</H3>
<blockquote>
<strong>HEY! READ THIS!</strong>
gd 2.0.2 creates PNG, JPEG and WBMP images, not GIF images. This is a
gd 2.0.3 creates PNG, JPEG and WBMP images, not GIF images. This is a
good thing. PNG is a more compact format, and full compression is
available. JPEG works best with photographic images, and is still
more compatible with the major Web browsers than even PNG is. WBMP is
@ -26,7 +26,7 @@ solution is to move to legally unencumbered, well-compressed,
modern image formats such as PNG and JPEG as soon as possible.
<p>
gd 2.0.2 <strong>requires</strong> that the following libraries
gd 2.0.3 <strong>requires</strong> that the following libraries
also be installed, in order to produce the related image formats:
<p>
libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>), if you want PNG
@ -56,7 +56,7 @@ information. Thank you!
<H3>Table of Contents</H3>
<UL>
<LI><A HREF="#notice">Credits and license terms</A>
<LI><A HREF="#whatsnew2.0.2">What's new in version "XYZ" of GD?</A>
<LI><A HREF="#whatsnew2.0.3">What's new in version "XYZ" of GD?</A>
<LI><A HREF="#whatis">What is gd?</A>
<LI><A HREF="#gdother">What if I want to use another programming language?</A>
<LI><A HREF="#required">What else do I need to use gd?</A>
@ -121,7 +121,7 @@ including but not limited to implied warranties of merchantability and
fitness for a particular purpose, with respect to this code and accompanying
documentation.
<p>
Although their code does not appear in gd 2.0.2, the authors wish to
Although their code does not appear in gd 2.0.3, the authors wish to
thank David Koblas, David Rowley, and Hutchison Avenue Software
Corporation for their prior contributions.
</blockquote>
@ -153,7 +153,7 @@ and so forth.
<A NAME="gdother"><H3>What if I want to use another programming
language?</h3></A>
Not all of these tools are necessarily up to date and fully compatible
with 2.0.2.
with 2.0.3.
<h4>Perl</h4>
gd can also be used from Perl, courtesy of
Lincoln Stein's
@ -177,6 +177,18 @@ invoke the interpreter.
<li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
</ul>
<P>
<A NAME="whatsnew2.0.3"><H3>What's new in version 2.0.3?</H3></A>
<ul>
<li>The <code>configure</code> script has been extensively modified
to work properly in tests with both Solaris and Linux. Other platforms
should also work based on feedback received and integrated to date.
<li>The <code>--prefix</code> option to <code>configure</code>
works properly.
<li>The <code>annotate</code> utility has been added. This is a
very handy tool for adding freetype text to existing JPEGs. After
<code>make install</code>, type <code>annotate -h</code> for more
information. Thanks to Joel Dubiner.
<P>
<A NAME="whatsnew2.0.2"><H3>What's new in version 2.0.2?</H3></A>
<ul>
<li>A "configure" script has been added. After wrestling with GNU
@ -622,13 +634,13 @@ saving of alpha channel information to the file instead.
<A NAME="getgd"><H3>How do I get gd?</H3></A>
<h4>By HTTP</h4>
<ul>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.2.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.2.zip">.ZIP File (Windows)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.3.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.3.zip">.ZIP File (Windows)</a>
</ul>
<h4>By FTP</h4>
<ul>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-2.0.2.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-2.0.2.zip">.ZIP File (Windows)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-2.0.3.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="ftp://ftp.boutell.com/pub/boutell/gd/gd-2.0.3.zip">.ZIP File (Windows)</a>
</ul>
<P>
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
@ -639,10 +651,10 @@ downloaded. If you are not familiar with <code>tar</code> and
consult with an experienced user of your system. Sorry, we cannot
answer questions about basic Internet skills.
<p>
Unpacking the archive will produce a directory called "gd-2.0.2".
Unpacking the archive will produce a directory called "gd-2.0.3".
<p>
<h4>For Unix</h4>
<code>cd</code> to the 2.0.2 directory and type:
<code>cd</code> to the 2.0.3 directory and type:
<p>
<code>./configure</code>
<p>