mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/exif: Minor refactoring of exif_thumbnail() (#16111)
This commit is contained in:
parent
fec2055af2
commit
291eef285c
2 changed files with 22 additions and 9 deletions
|
@ -4699,7 +4699,6 @@ PHP_FUNCTION(exif_read_data)
|
|||
PHP_FUNCTION(exif_thumbnail)
|
||||
{
|
||||
bool ret;
|
||||
int arg_c = ZEND_NUM_ARGS();
|
||||
image_info_type ImageInfo;
|
||||
zval *stream;
|
||||
zval *z_width = NULL, *z_height = NULL, *z_imagetype = NULL;
|
||||
|
@ -4731,7 +4730,7 @@ PHP_FUNCTION(exif_thumbnail)
|
|||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (CHECK_NULL_PATH(Z_STRVAL_P(stream), Z_STRLEN_P(stream))) {
|
||||
if (zend_str_has_nul_byte(Z_STR_P(stream))) {
|
||||
zend_argument_value_error(1, "must not contain any null bytes");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
@ -4756,17 +4755,19 @@ PHP_FUNCTION(exif_thumbnail)
|
|||
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thumbnail.size);
|
||||
#endif
|
||||
|
||||
ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size);
|
||||
if (arg_c >= 3) {
|
||||
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
|
||||
if (!exif_scan_thumbnail(&ImageInfo)) {
|
||||
ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0;
|
||||
}
|
||||
RETVAL_STRINGL(ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size);
|
||||
if ((z_width || z_height) && (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height)) {
|
||||
if (!exif_scan_thumbnail(&ImageInfo)) {
|
||||
ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0;
|
||||
}
|
||||
}
|
||||
if (z_width) {
|
||||
ZEND_TRY_ASSIGN_REF_LONG(z_width, ImageInfo.Thumbnail.width);
|
||||
}
|
||||
if (z_height) {
|
||||
ZEND_TRY_ASSIGN_REF_LONG(z_height, ImageInfo.Thumbnail.height);
|
||||
}
|
||||
if (arg_c >= 4) {
|
||||
if (z_imagetype) {
|
||||
ZEND_TRY_ASSIGN_REF_LONG(z_imagetype, ImageInfo.Thumbnail.filetype);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,19 @@ $fp = fopen(__DIR__ . '/sony.jpg', 'rb');
|
|||
|
||||
var_dump(strlen(exif_thumbnail($fp)));
|
||||
|
||||
exif_thumbnail($fp, width: $width);
|
||||
var_dump($width);
|
||||
|
||||
exif_thumbnail($fp, height: $height);
|
||||
var_dump($height);
|
||||
|
||||
exif_thumbnail($fp, image_type: $image_type);
|
||||
var_dump($image_type == IMAGETYPE_JPEG);
|
||||
|
||||
fclose($fp);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(4150)
|
||||
int(160)
|
||||
int(90)
|
||||
bool(true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue