summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--ext/standard/image.c37
-rw-r--r--ext/standard/image.h36
-rw-r--r--ext/standard/php3_standard.h2
-rw-r--r--ext/standard/php_image.h26
5 files changed, 51 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index af82a754ae..1b08d7e636 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ PHP 4.0 CHANGE LOG ChangeLog
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? 1999, Version 4.0 Beta 3
+- Ported newest GetImageSize (Thies)
- Added session compile support in Win32 (Andi)
- Added -d switch to the CGI binary that allows overriding php.ini values
from the command line (Zeev)
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 4628f38a2f..cdcdf84ada 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -45,7 +45,7 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include "image.h"
+#include "php_image.h"
/* file type markers */
const char php3_sig_gif[3] =
@@ -62,6 +62,8 @@ const char php3_sig_png[8] =
struct gfxinfo {
unsigned int width;
unsigned int height;
+ unsigned int bits;
+ unsigned int channels;
};
/* routine to handle GIF files. If only everything were that easy... ;} */
@@ -70,7 +72,7 @@ static struct gfxinfo *php3_handle_gif (FILE *fp)
struct gfxinfo *result = NULL;
unsigned char a[2];
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
fseek(fp, 6L, SEEK_SET);
fread(a,sizeof(a),1,fp);
result->width = (unsigned short)a[0] | (((unsigned short)a[1])<<8);
@@ -96,7 +98,7 @@ static struct gfxinfo *php3_handle_png(FILE *fp)
struct gfxinfo *result = NULL;
unsigned long in_width, in_height;
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
fseek(fp, 16L, SEEK_SET);
in_width = php3_read4(fp);
in_height = php3_read4(fp);
@@ -211,7 +213,6 @@ static struct gfxinfo *php3_handle_jpeg(FILE *fp,pval *info)
{
struct gfxinfo *result = NULL;
unsigned int marker;
- unsigned short in_width, in_height;
fseek(fp, 0L, SEEK_SET); /* position file pointer on SOF */
@@ -239,20 +240,20 @@ static struct gfxinfo *php3_handle_jpeg(FILE *fp,pval *info)
case M_SOF15:
if (result == NULL) {
/* handle SOFn block */
- fseek(fp, 3L, SEEK_CUR); /* skip length and precision bytes */
- in_height = php3_read2(fp);
- in_width = php3_read2(fp);
- /* fill a gfxinfo struct to return the data */
- result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo));
-
- result->width = (unsigned int) in_width;
- result->height = (unsigned int) in_height;
-
+ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
+
+ fseek(fp, 2, SEEK_CUR);
+
+ result->bits = fgetc(fp);
+ result->height = php3_read2(fp);
+ result->width = php3_read2(fp);
+ result->channels = fgetc(fp);
+
if (! info) /* if we don't want an extanded info -> return */
return result;
} else {
php3_skip_variable(fp);
- }
+ }
break;
case M_APP0:
@@ -321,6 +322,7 @@ PHP_FUNCTION(getimagesize)
}
pval_destructor(info);
+
if (array_init(info) == FAILURE) {
return;
}
@@ -369,6 +371,13 @@ PHP_FUNCTION(getimagesize)
add_index_long(return_value, 2, itype);
sprintf(temp, "width=\"%d\" height=\"%d\"", result->width, result->height); /* safe */
add_index_string(return_value, 3, temp, 1);
+
+ if (result->bits != 0) {
+ add_assoc_long(return_value,"bits",result->bits);
+ }
+ if (result->channels != 0) {
+ add_assoc_long(return_value,"channels",result->channels);
+ }
efree(result);
}
diff --git a/ext/standard/image.h b/ext/standard/image.h
deleted file mode 100644
index b6a7bde41e..0000000000
--- a/ext/standard/image.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf |
- +----------------------------------------------------------------------+
- */
-/* $Id$ */
-
-#ifndef _IMAGE_H
-#define _IMAGE_H
-
-PHP_FUNCTION(getimagesize);
-
-#endif /* _IMAGE_H */
diff --git a/ext/standard/php3_standard.h b/ext/standard/php3_standard.h
index 47fc165b87..c6a80cde65 100644
--- a/ext/standard/php3_standard.h
+++ b/ext/standard/php3_standard.h
@@ -53,7 +53,7 @@
#include "cyr_convert.h"
#include "php3_link.h"
#include "fsock.h"
-#include "image.h"
+#include "php_image.h"
#include "php3_iptc.h"
#include "info.h"
#include "uniqid.h"
diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h
new file mode 100644
index 0000000000..39dd9fa2fd
--- /dev/null
+++ b/ext/standard/php_image.h
@@ -0,0 +1,26 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.0 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_0.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Rasmus Lerdorf |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#ifndef _IMAGE_H
+#define _IMAGE_H
+
+PHP_FUNCTION(getimagesize);
+
+#endif /* _IMAGE_H */