Date: 08/04/99
- Next message: Bug Database: "[PHP-DEV] Bug #1956 Updated: Missing PNG functions for GD"
- Previous message: Bug Database: "[PHP-DEV] Bug #1960 Updated: intval() mangling values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
rasmus Wed Aug 4 14:51:56 1999 EDT
Modified files:
/php3 ChangeLog
/php3/functions gd.c php3_gd.h
Log:
Add gd-1.6.x PNG functions from drew <email protected>
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.736 php3/ChangeLog:1.737
--- php3/ChangeLog:1.736 Tue Aug 3 15:54:24 1999
+++ php3/ChangeLog Wed Aug 4 14:51:51 1999
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
???? ??, 1999, Version 3.0.13
+- Add gd-1.6.x PNG functions (Rasmus from drew <email protected>)
- Fix [s]printf 0-padding issues (Rasmus)
- Fix a crash bug in number_format(), in case of very large numbers (Zeev)
Index: php3/functions/gd.c
diff -u php3/functions/gd.c:1.130 php3/functions/gd.c:1.131
--- php3/functions/gd.c:1.130 Thu Jul 29 14:40:17 1999
+++ php3/functions/gd.c Wed Aug 4 14:51:53 1999
@@ -29,7 +29,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.130 1999/07/29 18:40:17 markonen Exp $ */
+/* $Id: gd.c,v 1.131 1999/08/04 18:51:53 rasmus Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -132,6 +132,9 @@
/* GIF support is gone from gd-1.6 */
{"imagecreatefromgif", php3_imagecreatefromgif, NULL},
{"imagegif", php3_imagegif, NULL},
+#else
+ {"imagecreatefrompng", php3_imagecreatefrompng, NULL},
+ {"imagepng", php3_imagepng, NULL},
#endif
{"imagedestroy", php3_imagedestroy, NULL},
{"imagefill", php3_imagefill, NULL},
@@ -483,6 +486,48 @@
RETURN_LONG(ind);
}
/* }}} */
+#else
+/* {{{ proto int imagecreatefrompng(string filename)
+Create a new image from file or URL */
+void php3_imagecreatefrompng (INTERNAL_FUNCTION_PARAMETERS) {
+ pval *file;
+ int ind;
+ gdImagePtr im;
+ char *fn=NULL;
+ FILE *fp;
+ int issock=0, socketd=0;
+ GD_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(file);
+
+ fn = file->value.str.val;
+
+#if WIN32|WINNT
+ fp = fopen(file->value.str.val, "rb");
+#else
+ fp = php3_fopen_wrapper(file->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd);
+#endif
+ if (!fp) {
+ php3_strip_url_passwd(fn);
+ php3_error(E_WARNING,
+ "ImageCreateFromPng: Unable to open %s for reading", fn);
+ RETURN_FALSE;
+ }
+
+ im = gdImageCreateFromPng (fp);
+
+ fflush(fp);
+ fclose(fp);
+
+ ind = php3_list_insert(im, GD_GLOBAL(le_gd));
+
+ RETURN_LONG(ind);
+}
+/* }}} */
#endif
/* {{{ proto int imagedestroy(int im)
@@ -853,6 +898,83 @@
if (output) {
gdImageGif (im, tmp);
+ fseek(tmp, 0, SEEK_SET);
+#if APACHE && defined(CHARSET_EBCDIC)
+ /* This is a binary file already: avoid EBCDIC->ASCII conversion */
+ ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
+#endif
+ while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
+ php3_write(buf, b);
+ }
+ }
+
+ fclose(tmp);
+ /* the temporary file is automatically deleted */
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+#else
+/* {{{ proto int imagepng(int im, string filename)
+Output image to browser or file */
+void php3_imagepng (INTERNAL_FUNCTION_PARAMETERS) {
+ pval *imgind, *file;
+ gdImagePtr im;
+ char *fn=NULL;
+ FILE *fp;
+ int argc;
+ int ind_type;
+ int output=1;
+ GD_TLS_VARS;
+
+ argc = ARG_COUNT(ht);
+ if (argc < 1 || argc > 2 || getParameters(ht, argc, &imgind, &file) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(imgind);
+
+ if (argc == 2) {
+ convert_to_string(file);
+ fn = file->value.str.val;
+ if (!fn || fn == empty_string || _php3_check_open_basedir(fn)) {
+ php3_error(E_WARNING, "ImagePng: Invalid filename");
+ RETURN_FALSE;
+ }
+ }
+
+ im = php3_list_find(imgind->value.lval, &ind_type);
+ if (!im || ind_type != GD_GLOBAL(le_gd)) {
+ php3_error(E_WARNING, "ImagePng: unable to find image pointer");
+ RETURN_FALSE;
+ }
+
+ if (argc == 2) {
+ fp = fopen(fn, "wb");
+ if (!fp) {
+ php3_error(E_WARNING, "ImagePng: unable to open %s for writing", fn);
+ RETURN_FALSE;
+ }
+ gdImagePng (im,fp);
+ fflush(fp);
+ fclose(fp);
+ }
+ else {
+ int b;
+ FILE *tmp;
+ char buf[4096];
+
+ tmp = tmpfile();
+ if (tmp == NULL) {
+ php3_error(E_WARNING, "Unable to open temporary file");
+ RETURN_FALSE;
+ }
+
+ output = php3_header();
+
+ if (output) {
+ gdImagePng (im, tmp);
fseek(tmp, 0, SEEK_SET);
#if APACHE && defined(CHARSET_EBCDIC)
/* This is a binary file already: avoid EBCDIC->ASCII conversion */
Index: php3/functions/php3_gd.h
diff -u php3/functions/php3_gd.h:1.35 php3/functions/php3_gd.h:1.36
--- php3/functions/php3_gd.h:1.35 Thu Jul 29 14:40:17 1999
+++ php3/functions/php3_gd.h Wed Aug 4 14:51:53 1999
@@ -29,7 +29,7 @@
*/
-/* $Id: php3_gd.h,v 1.35 1999/07/29 18:40:17 markonen Exp $ */
+/* $Id: php3_gd.h,v 1.36 1999/08/04 18:51:53 rasmus Exp $ */
#ifndef _PHP3_GD_H
#define _PHP3_GD_H
@@ -74,6 +74,7 @@
extern void php3_imagecopyresized(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagecreate(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagecreatefromgif (INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_imagecreatefrompng (INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagedestroy(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagefill(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagefilledpolygon(INTERNAL_FUNCTION_PARAMETERS);
@@ -82,6 +83,7 @@
extern void php3_imagefontwidth(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagefontheight(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imagegif (INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_imagepng (INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imageinterlace(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imageline(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_imageloadfont(INTERNAL_FUNCTION_PARAMETERS);
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Bug Database: "[PHP-DEV] Bug #1956 Updated: Missing PNG functions for GD"
- Previous message: Bug Database: "[PHP-DEV] Bug #1960 Updated: intval() mangling values"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

