newest GetImageSize renamed header-file

This commit is contained in:
Thies C. Arntzen 1999-09-02 11:58:23 +00:00
parent 5b52d07ea6
commit 9e959a0b8a
5 changed files with 51 additions and 51 deletions

View File

@ -2,6 +2,7 @@ PHP 4.0 CHANGE LOG ChangeLog
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? 1999, Version 4.0 Beta 3 ?? ?? 1999, Version 4.0 Beta 3
- Ported newest GetImageSize (Thies)
- Added session compile support in Win32 (Andi) - Added session compile support in Win32 (Andi)
- Added -d switch to the CGI binary that allows overriding php.ini values - Added -d switch to the CGI binary that allows overriding php.ini values
from the command line (Zeev) from the command line (Zeev)

View File

@ -45,7 +45,7 @@
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "image.h" #include "php_image.h"
/* file type markers */ /* file type markers */
const char php3_sig_gif[3] = const char php3_sig_gif[3] =
@ -62,6 +62,8 @@ const char php3_sig_png[8] =
struct gfxinfo { struct gfxinfo {
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int bits;
unsigned int channels;
}; };
/* routine to handle GIF files. If only everything were that easy... ;} */ /* 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; struct gfxinfo *result = NULL;
unsigned char a[2]; unsigned char a[2];
result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo)); result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
fseek(fp, 6L, SEEK_SET); fseek(fp, 6L, SEEK_SET);
fread(a,sizeof(a),1,fp); fread(a,sizeof(a),1,fp);
result->width = (unsigned short)a[0] | (((unsigned short)a[1])<<8); 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; struct gfxinfo *result = NULL;
unsigned long in_width, in_height; 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); fseek(fp, 16L, SEEK_SET);
in_width = php3_read4(fp); in_width = php3_read4(fp);
in_height = 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; struct gfxinfo *result = NULL;
unsigned int marker; unsigned int marker;
unsigned short in_width, in_height;
fseek(fp, 0L, SEEK_SET); /* position file pointer on SOF */ 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: case M_SOF15:
if (result == NULL) { if (result == NULL) {
/* handle SOFn block */ /* handle SOFn block */
fseek(fp, 3L, SEEK_CUR); /* skip length and precision bytes */ result = (struct gfxinfo *) ecalloc(1,sizeof(struct gfxinfo));
in_height = php3_read2(fp);
in_width = php3_read2(fp); fseek(fp, 2, SEEK_CUR);
/* fill a gfxinfo struct to return the data */
result = (struct gfxinfo *) emalloc(sizeof(struct gfxinfo)); result->bits = fgetc(fp);
result->height = php3_read2(fp);
result->width = (unsigned int) in_width; result->width = php3_read2(fp);
result->height = (unsigned int) in_height; result->channels = fgetc(fp);
if (! info) /* if we don't want an extanded info -> return */ if (! info) /* if we don't want an extanded info -> return */
return result; return result;
} else { } else {
php3_skip_variable(fp); php3_skip_variable(fp);
} }
break; break;
case M_APP0: case M_APP0:
@ -321,6 +322,7 @@ PHP_FUNCTION(getimagesize)
} }
pval_destructor(info); pval_destructor(info);
if (array_init(info) == FAILURE) { if (array_init(info) == FAILURE) {
return; return;
} }
@ -369,6 +371,13 @@ PHP_FUNCTION(getimagesize)
add_index_long(return_value, 2, itype); add_index_long(return_value, 2, itype);
sprintf(temp, "width=\"%d\" height=\"%d\"", result->width, result->height); /* safe */ sprintf(temp, "width=\"%d\" height=\"%d\"", result->width, result->height); /* safe */
add_index_string(return_value, 3, temp, 1); 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); efree(result);
} }

View File

@ -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 */

View File

@ -53,7 +53,7 @@
#include "cyr_convert.h" #include "cyr_convert.h"
#include "php3_link.h" #include "php3_link.h"
#include "fsock.h" #include "fsock.h"
#include "image.h" #include "php_image.h"
#include "php3_iptc.h" #include "php3_iptc.h"
#include "info.h" #include "info.h"
#include "uniqid.h" #include "uniqid.h"

26
ext/standard/php_image.h Normal file
View File

@ -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 */