ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_pcd Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Inheritance diagram for getid3_pcd:
+ Collaboration diagram for getid3_pcd:

Public Member Functions

 getid3_pcd (&$fd, &$ThisFileInfo, $ExtractData=0)
 
 YCbCr2RGB ($Y, $Cb, $Cr)
 
 Analyze ()
 
 YCbCr2RGB ($Y, $Cb, $Cr)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Data Fields

 $ExtractData = 0
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 17 of file module.graphic.pcd.php.

Member Function Documentation

◆ Analyze()

getid3_pcd::Analyze ( )

Definition at line 22 of file module.graphic.pcd.php.

References $info, $x, $y, getid3_handler\fread(), getid3_handler\fseek(), and YCbCr2RGB().

22  {
23  $info = &$this->getid3->info;
24 
25  $info['fileformat'] = 'pcd';
26  $info['video']['dataformat'] = 'pcd';
27  $info['video']['lossless'] = false;
28 
29 
30  $this->fseek($info['avdataoffset'] + 72);
31 
32  $PCDflags = $this->fread(1);
33  $PCDisVertical = ((ord($PCDflags) & 0x01) ? true : false);
34 
35 
36  if ($PCDisVertical) {
37  $info['video']['resolution_x'] = 3072;
38  $info['video']['resolution_y'] = 2048;
39  } else {
40  $info['video']['resolution_x'] = 2048;
41  $info['video']['resolution_y'] = 3072;
42  }
43 
44 
45  if ($this->ExtractData > 3) {
46 
47  $info['error'][] = 'Cannot extract PSD image data for detail levels above BASE (level-3) because encrypted with Kodak-proprietary compression/encryption.';
48 
49  } elseif ($this->ExtractData > 0) {
50 
51  $PCD_levels[1] = array( 192, 128, 0x02000); // BASE/16
52  $PCD_levels[2] = array( 384, 256, 0x0B800); // BASE/4
53  $PCD_levels[3] = array( 768, 512, 0x30000); // BASE
54  //$PCD_levels[4] = array(1536, 1024, ??); // BASE*4 - encrypted with Kodak-proprietary compression/encryption
55  //$PCD_levels[5] = array(3072, 2048, ??); // BASE*16 - encrypted with Kodak-proprietary compression/encryption
56  //$PCD_levels[6] = array(6144, 4096, ??); // BASE*64 - encrypted with Kodak-proprietary compression/encryption; PhotoCD-Pro only
57 
58  list($PCD_width, $PCD_height, $PCD_dataOffset) = $PCD_levels[3];
59 
60  $this->fseek($info['avdataoffset'] + $PCD_dataOffset);
61 
62  for ($y = 0; $y < $PCD_height; $y += 2) {
63  // The image-data of these subtypes start at the respective offsets of 02000h, 0b800h and 30000h.
64  // To decode the YcbYr to the more usual RGB-code, three lines of data have to be read, each
65  // consisting of ‘wÂ’ bytes, where ‘wÂ’ is the width of the image-subtype. The first ‘wÂ’ bytes and
66  // the first half of the third ‘wÂ’ bytes contain data for the first RGB-line, the second ‘wÂ’ bytes
67  // and the second half of the third ‘wÂ’ bytes contain data for a second RGB-line.
68 
69  $PCD_data_Y1 = $this->fread($PCD_width);
70  $PCD_data_Y2 = $this->fread($PCD_width);
71  $PCD_data_Cb = $this->fread(intval(round($PCD_width / 2)));
72  $PCD_data_Cr = $this->fread(intval(round($PCD_width / 2)));
73 
74  for ($x = 0; $x < $PCD_width; $x++) {
75  if ($PCDisVertical) {
76  $info['pcd']['data'][$PCD_width - $x][$y] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
77  $info['pcd']['data'][$PCD_width - $x][$y + 1] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
78  } else {
79  $info['pcd']['data'][$y][$x] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
80  $info['pcd']['data'][$y + 1][$x] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
81  }
82  }
83  }
84 
85  // Example for plotting extracted data
86  //getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true);
87  //if ($PCDisVertical) {
88  // $BMPinfo['resolution_x'] = $PCD_height;
89  // $BMPinfo['resolution_y'] = $PCD_width;
90  //} else {
91  // $BMPinfo['resolution_x'] = $PCD_width;
92  // $BMPinfo['resolution_y'] = $PCD_height;
93  //}
94  //$BMPinfo['bmp']['data'] = $info['pcd']['data'];
95  //getid3_bmp::PlotBMP($BMPinfo);
96  //exit;
97 
98  }
99 
100  }
$x
Definition: example_009.php:98
YCbCr2RGB($Y, $Cb, $Cr)
$info
Definition: example_052.php:80
$y
Definition: example_007.php:83
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

◆ getid3_pcd()

getid3_pcd::getid3_pcd ( $fd,
$ThisFileInfo,
  $ExtractData = 0 
)

Definition at line 19 of file module.graphic.pcd.php.

References $ExtractData, $x, $y, getid3_handler\fread(), getid3_handler\fseek(), and YCbCr2RGB().

19  {
20  $ThisFileInfo['fileformat'] = 'pcd';
21  $ThisFileInfo['video']['dataformat'] = 'pcd';
22  $ThisFileInfo['video']['lossless'] = false;
23 
24 
25  fseek($fd, $ThisFileInfo['avdataoffset'] + 72, SEEK_SET);
26 
27  $PCDflags = fread($fd, 1);
28  $PCDisVertical = ((ord($PCDflags) & 0x01) ? true : false);
29 
30 
31  if ($PCDisVertical) {
32  $ThisFileInfo['video']['resolution_x'] = 3072;
33  $ThisFileInfo['video']['resolution_y'] = 2048;
34  } else {
35  $ThisFileInfo['video']['resolution_x'] = 2048;
36  $ThisFileInfo['video']['resolution_y'] = 3072;
37  }
38 
39 
40  if ($ExtractData > 3) {
41 
42  $ThisFileInfo['error'][] = 'Cannot extract PSD image data for detail levels above BASE (3)';
43 
44  } elseif ($ExtractData > 0) {
45 
46  $PCD_levels[1] = array( 192, 128, 0x02000); // BASE/16
47  $PCD_levels[2] = array( 384, 256, 0x0B800); // BASE/4
48  $PCD_levels[3] = array( 768, 512, 0x30000); // BASE
49  //$PCD_levels[4] = array(1536, 1024, ??); // BASE*4 - encrypted with Kodak-proprietary compression/encryption
50  //$PCD_levels[5] = array(3072, 2048, ??); // BASE*16 - encrypted with Kodak-proprietary compression/encryption
51  //$PCD_levels[6] = array(6144, 4096, ??); // BASE*64 - encrypted with Kodak-proprietary compression/encryption; PhotoCD-Pro only
52 
53  list($PCD_width, $PCD_height, $PCD_dataOffset) = $PCD_levels[3];
54 
55  fseek($fd, $ThisFileInfo['avdataoffset'] + $PCD_dataOffset, SEEK_SET);
56 
57  for ($y = 0; $y < $PCD_height; $y += 2) {
58  // The image-data of these subtypes start at the respective offsets of 02000h, 0b800h and 30000h.
59  // To decode the YcbYr to the more usual RGB-code, three lines of data have to be read, each
60  // consisting of ‘w’ bytes, where ‘w’ is the width of the image-subtype. The first ‘w’ bytes and
61  // the first half of the third ‘w’ bytes contain data for the first RGB-line, the second ‘w’ bytes
62  // and the second half of the third ‘w’ bytes contain data for a second RGB-line.
63 
64  $PCD_data_Y1 = fread($fd, $PCD_width);
65  $PCD_data_Y2 = fread($fd, $PCD_width);
66  $PCD_data_Cb = fread($fd, intval(round($PCD_width / 2)));
67  $PCD_data_Cr = fread($fd, intval(round($PCD_width / 2)));
68 
69  for ($x = 0; $x < $PCD_width; $x++) {
70  if ($PCDisVertical) {
71  $ThisFileInfo['pcd']['data'][$PCD_width - $x][$y] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
72  $ThisFileInfo['pcd']['data'][$PCD_width - $x][$y + 1] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
73  } else {
74  $ThisFileInfo['pcd']['data'][$y][$x] = $this->YCbCr2RGB(ord($PCD_data_Y1{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
75  $ThisFileInfo['pcd']['data'][$y + 1][$x] = $this->YCbCr2RGB(ord($PCD_data_Y2{$x}), ord($PCD_data_Cb{floor($x / 2)}), ord($PCD_data_Cr{floor($x / 2)}));
76  }
77  }
78  }
79 
80  // Example for plotting extracted data
81  //getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true);
82  //if ($PCDisVertical) {
83  // $BMPinfo['resolution_x'] = $PCD_height;
84  // $BMPinfo['resolution_y'] = $PCD_width;
85  //} else {
86  // $BMPinfo['resolution_x'] = $PCD_width;
87  // $BMPinfo['resolution_y'] = $PCD_height;
88  //}
89  //$BMPinfo['bmp']['data'] = $ThisFileInfo['pcd']['data'];
90  //getid3_bmp::PlotBMP($BMPinfo);
91  //exit;
92 
93  }
94 
95  }
$x
Definition: example_009.php:98
YCbCr2RGB($Y, $Cb, $Cr)
$y
Definition: example_007.php:83
fread($bytes)
Definition: getid3.php:1685
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1697
+ Here is the call graph for this function:

◆ YCbCr2RGB() [1/2]

getid3_pcd::YCbCr2RGB (   $Y,
  $Cb,
  $Cr 
)

Definition at line 97 of file module.graphic.pcd.php.

Referenced by Analyze(), and getid3_pcd().

97  {
98  static $YCbCr_constants = array();
99  if (empty($YCbCr_constants)) {
100  $YCbCr_constants['red']['Y'] = 0.0054980 * 256;
101  $YCbCr_constants['red']['Cb'] = 0.0000000 * 256;
102  $YCbCr_constants['red']['Cr'] = 0.0051681 * 256;
103  $YCbCr_constants['green']['Y'] = 0.0054980 * 256;
104  $YCbCr_constants['green']['Cb'] = -0.0015446 * 256;
105  $YCbCr_constants['green']['Cr'] = -0.0026325 * 256;
106  $YCbCr_constants['blue']['Y'] = 0.0054980 * 256;
107  $YCbCr_constants['blue']['Cb'] = 0.0079533 * 256;
108  $YCbCr_constants['blue']['Cr'] = 0.0000000 * 256;
109  }
110 
111  $RGBcolor = array('red'=>0, 'green'=>0, 'blue'=>0);
112  foreach ($RGBcolor as $rgbname => $dummy) {
113  $RGBcolor[$rgbname] = max(0,
114  min(255,
115  intval(
116  round(
117  ($YCbCr_constants[$rgbname]['Y'] * $Y) +
118  ($YCbCr_constants[$rgbname]['Cb'] * ($Cb - 156)) +
119  ($YCbCr_constants[$rgbname]['Cr'] * ($Cr - 137))
120  )
121  )
122  )
123  );
124  }
125  return (($RGBcolor['red'] * 65536) + ($RGBcolor['green'] * 256) + $RGBcolor['blue']);
126  }
+ Here is the caller graph for this function:

◆ YCbCr2RGB() [2/2]

getid3_pcd::YCbCr2RGB (   $Y,
  $Cb,
  $Cr 
)

Definition at line 102 of file module.graphic.pcd.php.

102  {
103  static $YCbCr_constants = array();
104  if (empty($YCbCr_constants)) {
105  $YCbCr_constants['red']['Y'] = 0.0054980 * 256;
106  $YCbCr_constants['red']['Cb'] = 0.0000000 * 256;
107  $YCbCr_constants['red']['Cr'] = 0.0051681 * 256;
108  $YCbCr_constants['green']['Y'] = 0.0054980 * 256;
109  $YCbCr_constants['green']['Cb'] = -0.0015446 * 256;
110  $YCbCr_constants['green']['Cr'] = -0.0026325 * 256;
111  $YCbCr_constants['blue']['Y'] = 0.0054980 * 256;
112  $YCbCr_constants['blue']['Cb'] = 0.0079533 * 256;
113  $YCbCr_constants['blue']['Cr'] = 0.0000000 * 256;
114  }
115 
116  $RGBcolor = array('red'=>0, 'green'=>0, 'blue'=>0);
117  foreach ($RGBcolor as $rgbname => $dummy) {
118  $RGBcolor[$rgbname] = max(0,
119  min(255,
120  intval(
121  round(
122  ($YCbCr_constants[$rgbname]['Y'] * $Y) +
123  ($YCbCr_constants[$rgbname]['Cb'] * ($Cb - 156)) +
124  ($YCbCr_constants[$rgbname]['Cr'] * ($Cr - 137))
125  )
126  )
127  )
128  );
129  }
130  return (($RGBcolor['red'] * 65536) + ($RGBcolor['green'] * 256) + $RGBcolor['blue']);
131  }

Field Documentation

◆ $ExtractData

getid3_pcd::$ExtractData = 0

Definition at line 20 of file module.graphic.pcd.php.

Referenced by getid3_pcd().


The documentation for this class was generated from the following file: