php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
image.c File Reference
#include "php.h"
#include <stdio.h>
#include "fopen_wrappers.h"
#include "ext/standard/fsock.h"
#include "libavifinfo/avifinfo.h"
#include "php_image.h"

Go to the source code of this file.

Data Structures

struct  gfxinfo
 
struct  php_avif_stream
 

Macros

#define M_SOF0   0xC0 /* Start Of Frame N */
 
#define M_SOF1   0xC1 /* N indicates which compression process */
 
#define M_SOF2   0xC2 /* Only SOF0-SOF2 are now in common use */
 
#define M_SOF3   0xC3
 
#define M_SOF5   0xC5 /* NB: codes C4 and CC are NOT SOF markers */
 
#define M_SOF6   0xC6
 
#define M_SOF7   0xC7
 
#define M_SOF9   0xC9
 
#define M_SOF10   0xCA
 
#define M_SOF11   0xCB
 
#define M_SOF13   0xCD
 
#define M_SOF14   0xCE
 
#define M_SOF15   0xCF
 
#define M_SOI   0xD8
 
#define M_EOI   0xD9 /* End Of Image (end of datastream) */
 
#define M_SOS   0xDA /* Start Of Scan (begins compressed data) */
 
#define M_APP0   0xe0
 
#define M_APP1   0xe1
 
#define M_APP2   0xe2
 
#define M_APP3   0xe3
 
#define M_APP4   0xe4
 
#define M_APP5   0xe5
 
#define M_APP6   0xe6
 
#define M_APP7   0xe7
 
#define M_APP8   0xe8
 
#define M_APP9   0xe9
 
#define M_APP10   0xea
 
#define M_APP11   0xeb
 
#define M_APP12   0xec
 
#define M_APP13   0xed
 
#define M_APP14   0xee
 
#define M_APP15   0xef
 
#define M_COM   0xFE /* COMment */
 
#define M_PSEUDO   0xFFD8 /* pseudo marker for start of image(byte 0) */
 
#define JPEG2000_MARKER_PREFIX   0xFF /* All marker codes start with this */
 
#define JPEG2000_MARKER_SOC   0x4F /* Start of Codestream */
 
#define JPEG2000_MARKER_SOT   0x90 /* Start of Tile part */
 
#define JPEG2000_MARKER_SOD   0x93 /* Start of Data */
 
#define JPEG2000_MARKER_EOC   0xD9 /* End of Codestream */
 
#define JPEG2000_MARKER_SIZ   0x51 /* Image and tile size */
 
#define JPEG2000_MARKER_COD   0x52 /* Coding style default */
 
#define JPEG2000_MARKER_COC   0x53 /* Coding style component */
 
#define JPEG2000_MARKER_RGN   0x5E /* Region of interest */
 
#define JPEG2000_MARKER_QCD   0x5C /* Quantization default */
 
#define JPEG2000_MARKER_QCC   0x5D /* Quantization component */
 
#define JPEG2000_MARKER_POC   0x5F /* Progression order change */
 
#define JPEG2000_MARKER_TLM   0x55 /* Tile-part lengths */
 
#define JPEG2000_MARKER_PLM   0x57 /* Packet length, main header */
 
#define JPEG2000_MARKER_PLT   0x58 /* Packet length, tile-part header */
 
#define JPEG2000_MARKER_PPM   0x60 /* Packed packet headers, main header */
 
#define JPEG2000_MARKER_PPT   0x61 /* Packed packet headers, tile part header */
 
#define JPEG2000_MARKER_SOP   0x91 /* Start of packet */
 
#define JPEG2000_MARKER_EPH   0x92 /* End of packet header */
 
#define JPEG2000_MARKER_CRG   0x63 /* Component registration */
 
#define JPEG2000_MARKER_COM   0x64 /* Comment */
 
#define TAG_IMAGEWIDTH   0x0100
 
#define TAG_IMAGEHEIGHT   0x0101
 
#define TAG_COMP_IMAGEWIDTH   0xA002
 
#define TAG_COMP_IMAGEHEIGHT   0xA003
 
#define TAG_FMT_BYTE   1
 
#define TAG_FMT_STRING   2
 
#define TAG_FMT_USHORT   3
 
#define TAG_FMT_ULONG   4
 
#define TAG_FMT_URATIONAL   5
 
#define TAG_FMT_SBYTE   6
 
#define TAG_FMT_UNDEFINED   7
 
#define TAG_FMT_SSHORT   8
 
#define TAG_FMT_SLONG   9
 
#define TAG_FMT_SRATIONAL   10
 
#define TAG_FMT_SINGLE   11
 
#define TAG_FMT_DOUBLE   12
 
#define FROM_DATA   0
 
#define FROM_PATH   1
 

Functions

bool php_is_image_avif (php_stream *stream)
 
PHPAPI char * php_image_type_to_mime_type (int image_type)
 
 PHP_FUNCTION (image_type_to_mime_type)
 
 PHP_FUNCTION (image_type_to_extension)
 
PHPAPI int php_getimagetype (php_stream *stream, const char *input, char *filetype)
 
 PHP_FUNCTION (getimagesize)
 
 PHP_FUNCTION (getimagesizefromstring)
 

Variables

PHPAPI const char php_sig_gif [3] = {'G', 'I', 'F'}
 
PHPAPI const char php_sig_psd [4] = {'8', 'B', 'P', 'S'}
 
PHPAPI const char php_sig_bmp [2] = {'B', 'M'}
 
PHPAPI const char php_sig_swf [3] = {'F', 'W', 'S'}
 
PHPAPI const char php_sig_swc [3] = {'C', 'W', 'S'}
 
PHPAPI const char php_sig_jpg [3] = {(char) 0xff, (char) 0xd8, (char) 0xff}
 
PHPAPI const char php_sig_png [8]
 
PHPAPI const char php_sig_tif_ii [4] = {'I','I', (char)0x2A, (char)0x00}
 
PHPAPI const char php_sig_tif_mm [4] = {'M','M', (char)0x00, (char)0x2A}
 
PHPAPI const char php_sig_jpc [3] = {(char)0xff, (char)0x4f, (char)0xff}
 
PHPAPI const char php_sig_jp2 [12]
 
PHPAPI const char php_sig_iff [4] = {'F','O','R','M'}
 
PHPAPI const char php_sig_ico [4] = {(char)0x00, (char)0x00, (char)0x01, (char)0x00}
 
PHPAPI const char php_sig_riff [4] = {'R', 'I', 'F', 'F'}
 
PHPAPI const char php_sig_webp [4] = {'W', 'E', 'B', 'P'}
 
PHPAPI const int php_tiff_bytes_per_format [] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8}
 

Macro Definition Documentation

◆ FROM_DATA

#define FROM_DATA   0

Definition at line 1541 of file image.c.

◆ FROM_PATH

#define FROM_PATH   1

Definition at line 1542 of file image.c.

◆ JPEG2000_MARKER_COC

#define JPEG2000_MARKER_COC   0x53 /* Coding style component */

Definition at line 556 of file image.c.

◆ JPEG2000_MARKER_COD

#define JPEG2000_MARKER_COD   0x52 /* Coding style default */

Definition at line 555 of file image.c.

◆ JPEG2000_MARKER_COM

#define JPEG2000_MARKER_COM   0x64 /* Comment */

Definition at line 569 of file image.c.

◆ JPEG2000_MARKER_CRG

#define JPEG2000_MARKER_CRG   0x63 /* Component registration */

Definition at line 568 of file image.c.

◆ JPEG2000_MARKER_EOC

#define JPEG2000_MARKER_EOC   0xD9 /* End of Codestream */

Definition at line 553 of file image.c.

◆ JPEG2000_MARKER_EPH

#define JPEG2000_MARKER_EPH   0x92 /* End of packet header */

Definition at line 567 of file image.c.

◆ JPEG2000_MARKER_PLM

#define JPEG2000_MARKER_PLM   0x57 /* Packet length, main header */

Definition at line 562 of file image.c.

◆ JPEG2000_MARKER_PLT

#define JPEG2000_MARKER_PLT   0x58 /* Packet length, tile-part header */

Definition at line 563 of file image.c.

◆ JPEG2000_MARKER_POC

#define JPEG2000_MARKER_POC   0x5F /* Progression order change */

Definition at line 560 of file image.c.

◆ JPEG2000_MARKER_PPM

#define JPEG2000_MARKER_PPM   0x60 /* Packed packet headers, main header */

Definition at line 564 of file image.c.

◆ JPEG2000_MARKER_PPT

#define JPEG2000_MARKER_PPT   0x61 /* Packed packet headers, tile part header */

Definition at line 565 of file image.c.

◆ JPEG2000_MARKER_PREFIX

#define JPEG2000_MARKER_PREFIX   0xFF /* All marker codes start with this */

Definition at line 549 of file image.c.

◆ JPEG2000_MARKER_QCC

#define JPEG2000_MARKER_QCC   0x5D /* Quantization component */

Definition at line 559 of file image.c.

◆ JPEG2000_MARKER_QCD

#define JPEG2000_MARKER_QCD   0x5C /* Quantization default */

Definition at line 558 of file image.c.

◆ JPEG2000_MARKER_RGN

#define JPEG2000_MARKER_RGN   0x5E /* Region of interest */

Definition at line 557 of file image.c.

◆ JPEG2000_MARKER_SIZ

#define JPEG2000_MARKER_SIZ   0x51 /* Image and tile size */

Definition at line 554 of file image.c.

◆ JPEG2000_MARKER_SOC

#define JPEG2000_MARKER_SOC   0x4F /* Start of Codestream */

Definition at line 550 of file image.c.

◆ JPEG2000_MARKER_SOD

#define JPEG2000_MARKER_SOD   0x93 /* Start of Data */

Definition at line 552 of file image.c.

◆ JPEG2000_MARKER_SOP

#define JPEG2000_MARKER_SOP   0x91 /* Start of packet */

Definition at line 566 of file image.c.

◆ JPEG2000_MARKER_SOT

#define JPEG2000_MARKER_SOT   0x90 /* Start of Tile part */

Definition at line 551 of file image.c.

◆ JPEG2000_MARKER_TLM

#define JPEG2000_MARKER_TLM   0x55 /* Tile-part lengths */

Definition at line 561 of file image.c.

◆ M_APP0

#define M_APP0   0xe0

Definition at line 314 of file image.c.

◆ M_APP1

#define M_APP1   0xe1

Definition at line 315 of file image.c.

◆ M_APP10

#define M_APP10   0xea

Definition at line 324 of file image.c.

◆ M_APP11

#define M_APP11   0xeb

Definition at line 325 of file image.c.

◆ M_APP12

#define M_APP12   0xec

Definition at line 326 of file image.c.

◆ M_APP13

#define M_APP13   0xed

Definition at line 327 of file image.c.

◆ M_APP14

#define M_APP14   0xee

Definition at line 328 of file image.c.

◆ M_APP15

#define M_APP15   0xef

Definition at line 329 of file image.c.

◆ M_APP2

#define M_APP2   0xe2

Definition at line 316 of file image.c.

◆ M_APP3

#define M_APP3   0xe3

Definition at line 317 of file image.c.

◆ M_APP4

#define M_APP4   0xe4

Definition at line 318 of file image.c.

◆ M_APP5

#define M_APP5   0xe5

Definition at line 319 of file image.c.

◆ M_APP6

#define M_APP6   0xe6

Definition at line 320 of file image.c.

◆ M_APP7

#define M_APP7   0xe7

Definition at line 321 of file image.c.

◆ M_APP8

#define M_APP8   0xe8

Definition at line 322 of file image.c.

◆ M_APP9

#define M_APP9   0xe9

Definition at line 323 of file image.c.

◆ M_COM

#define M_COM   0xFE /* COMment */

Definition at line 330 of file image.c.

◆ M_EOI

#define M_EOI   0xD9 /* End Of Image (end of datastream) */

Definition at line 312 of file image.c.

◆ M_PSEUDO

#define M_PSEUDO   0xFFD8 /* pseudo marker for start of image(byte 0) */

Definition at line 332 of file image.c.

◆ M_SOF0

#define M_SOF0   0xC0 /* Start Of Frame N */

Definition at line 298 of file image.c.

◆ M_SOF1

#define M_SOF1   0xC1 /* N indicates which compression process */

Definition at line 299 of file image.c.

◆ M_SOF10

#define M_SOF10   0xCA

Definition at line 306 of file image.c.

◆ M_SOF11

#define M_SOF11   0xCB

Definition at line 307 of file image.c.

◆ M_SOF13

#define M_SOF13   0xCD

Definition at line 308 of file image.c.

◆ M_SOF14

#define M_SOF14   0xCE

Definition at line 309 of file image.c.

◆ M_SOF15

#define M_SOF15   0xCF

Definition at line 310 of file image.c.

◆ M_SOF2

#define M_SOF2   0xC2 /* Only SOF0-SOF2 are now in common use */

Definition at line 300 of file image.c.

◆ M_SOF3

#define M_SOF3   0xC3

Definition at line 301 of file image.c.

◆ M_SOF5

#define M_SOF5   0xC5 /* NB: codes C4 and CC are NOT SOF markers */

Definition at line 302 of file image.c.

◆ M_SOF6

#define M_SOF6   0xC6

Definition at line 303 of file image.c.

◆ M_SOF7

#define M_SOF7   0xC7

Definition at line 304 of file image.c.

◆ M_SOF9

#define M_SOF9   0xC9

Definition at line 305 of file image.c.

◆ M_SOI

#define M_SOI   0xD8

Definition at line 311 of file image.c.

◆ M_SOS

#define M_SOS   0xDA /* Start Of Scan (begins compressed data) */

Definition at line 313 of file image.c.

◆ TAG_COMP_IMAGEHEIGHT

#define TAG_COMP_IMAGEHEIGHT   0xA003

Definition at line 711 of file image.c.

◆ TAG_COMP_IMAGEWIDTH

#define TAG_COMP_IMAGEWIDTH   0xA002

Definition at line 710 of file image.c.

◆ TAG_FMT_BYTE

#define TAG_FMT_BYTE   1

Definition at line 713 of file image.c.

◆ TAG_FMT_DOUBLE

#define TAG_FMT_DOUBLE   12

Definition at line 724 of file image.c.

◆ TAG_FMT_SBYTE

#define TAG_FMT_SBYTE   6

Definition at line 718 of file image.c.

◆ TAG_FMT_SINGLE

#define TAG_FMT_SINGLE   11

Definition at line 723 of file image.c.

◆ TAG_FMT_SLONG

#define TAG_FMT_SLONG   9

Definition at line 721 of file image.c.

◆ TAG_FMT_SRATIONAL

#define TAG_FMT_SRATIONAL   10

Definition at line 722 of file image.c.

◆ TAG_FMT_SSHORT

#define TAG_FMT_SSHORT   8

Definition at line 720 of file image.c.

◆ TAG_FMT_STRING

#define TAG_FMT_STRING   2

Definition at line 714 of file image.c.

◆ TAG_FMT_ULONG

#define TAG_FMT_ULONG   4

Definition at line 716 of file image.c.

◆ TAG_FMT_UNDEFINED

#define TAG_FMT_UNDEFINED   7

Definition at line 719 of file image.c.

◆ TAG_FMT_URATIONAL

#define TAG_FMT_URATIONAL   5

Definition at line 717 of file image.c.

◆ TAG_FMT_USHORT

#define TAG_FMT_USHORT   3

Definition at line 715 of file image.c.

◆ TAG_IMAGEHEIGHT

#define TAG_IMAGEHEIGHT   0x0101

Definition at line 708 of file image.c.

◆ TAG_IMAGEWIDTH

#define TAG_IMAGEWIDTH   0x0100

Definition at line 707 of file image.c.

Function Documentation

◆ PHP_FUNCTION() [1/4]

PHP_FUNCTION ( getimagesize )

Definition at line 1584 of file image.c.

◆ PHP_FUNCTION() [2/4]

PHP_FUNCTION ( getimagesizefromstring )

Definition at line 1591 of file image.c.

◆ PHP_FUNCTION() [3/4]

PHP_FUNCTION ( image_type_to_extension )

Definition at line 1273 of file image.c.

◆ PHP_FUNCTION() [4/4]

PHP_FUNCTION ( image_type_to_mime_type )

Definition at line 1260 of file image.c.

◆ php_getimagetype()

PHPAPI int php_getimagetype ( php_stream * stream,
const char * input,
char * filetype )

Definition at line 1349 of file image.c.

◆ php_image_type_to_mime_type()

PHPAPI char * php_image_type_to_mime_type ( int image_type)

Definition at line 1217 of file image.c.

◆ php_is_image_avif()

bool php_is_image_avif ( php_stream * stream)

Definition at line 1204 of file image.c.

Variable Documentation

◆ php_sig_bmp

PHPAPI const char php_sig_bmp[2] = {'B', 'M'}

Definition at line 38 of file image.c.

◆ php_sig_gif

PHPAPI const char php_sig_gif[3] = {'G', 'I', 'F'}

Definition at line 36 of file image.c.

◆ php_sig_ico

PHPAPI const char php_sig_ico[4] = {(char)0x00, (char)0x00, (char)0x01, (char)0x00}

Definition at line 51 of file image.c.

◆ php_sig_iff

PHPAPI const char php_sig_iff[4] = {'F','O','R','M'}

Definition at line 50 of file image.c.

◆ php_sig_jp2

PHPAPI const char php_sig_jp2[12]
Initial value:
= {(char)0x00, (char)0x00, (char)0x00, (char)0x0c,
(char)0x6a, (char)0x50, (char)0x20, (char)0x20,
(char)0x0d, (char)0x0a, (char)0x87, (char)0x0a}

Definition at line 47 of file image.c.

◆ php_sig_jpc

PHPAPI const char php_sig_jpc[3] = {(char)0xff, (char)0x4f, (char)0xff}

Definition at line 46 of file image.c.

◆ php_sig_jpg

PHPAPI const char php_sig_jpg[3] = {(char) 0xff, (char) 0xd8, (char) 0xff}

Definition at line 41 of file image.c.

◆ php_sig_png

PHPAPI const char php_sig_png[8]
Initial value:
= {(char) 0x89, (char) 0x50, (char) 0x4e, (char) 0x47,
(char) 0x0d, (char) 0x0a, (char) 0x1a, (char) 0x0a}

Definition at line 42 of file image.c.

◆ php_sig_psd

PHPAPI const char php_sig_psd[4] = {'8', 'B', 'P', 'S'}

Definition at line 37 of file image.c.

◆ php_sig_riff

PHPAPI const char php_sig_riff[4] = {'R', 'I', 'F', 'F'}

Definition at line 52 of file image.c.

◆ php_sig_swc

PHPAPI const char php_sig_swc[3] = {'C', 'W', 'S'}

Definition at line 40 of file image.c.

◆ php_sig_swf

PHPAPI const char php_sig_swf[3] = {'F', 'W', 'S'}

Definition at line 39 of file image.c.

◆ php_sig_tif_ii

PHPAPI const char php_sig_tif_ii[4] = {'I','I', (char)0x2A, (char)0x00}

Definition at line 44 of file image.c.

◆ php_sig_tif_mm

PHPAPI const char php_sig_tif_mm[4] = {'M','M', (char)0x00, (char)0x2A}

Definition at line 45 of file image.c.

◆ php_sig_webp

PHPAPI const char php_sig_webp[4] = {'W', 'E', 'B', 'P'}

Definition at line 53 of file image.c.

◆ php_tiff_bytes_per_format

PHPAPI const int php_tiff_bytes_per_format[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8}

Definition at line 704 of file image.c.