]> granicus.if.org Git - php/commitdiff
newest GetImageSize renamed header-file
authorThies C. Arntzen <thies@php.net>
Thu, 2 Sep 1999 11:58:23 +0000 (11:58 +0000)
committerThies C. Arntzen <thies@php.net>
Thu, 2 Sep 1999 11:58:23 +0000 (11:58 +0000)
ChangeLog
ext/standard/image.c
ext/standard/image.h [deleted file]
ext/standard/php3_standard.h
ext/standard/php_image.h [new file with mode: 0644]

index af82a754ae3c2ac0b13d69cbe6f81db927834717..1b08d7e63649c3d8442491c0bbeb466584f2856d 100644 (file)
--- 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)
index 4628f38a2f504655231be130cc4c6b5ef75c8023..cdcdf84ada644edb229fc93622ba72d8fbfefdb7 100644 (file)
@@ -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 (file)
index b6a7bde..0000000
+++ /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 */
index 47fc165b8705d5785f2abe2c60a464990abc55dc..c6a80cde65c3577257d12625c3a18bc7e5e0a84b 100644 (file)
@@ -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 (file)
index 0000000..39dd9fa
--- /dev/null
@@ -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 */