ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Graphic\Pcd Class Reference

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

+ Inheritance diagram for GetId3\Module\Graphic\Pcd:
+ Collaboration diagram for GetId3\Module\Graphic\Pcd:

Public Member Functions

 analyze ()
 Analyze from file pointer. More...
 
 YCbCr2RGB ($Y, $Cb, $Cr)
 @staticvar array $YCbCr_constants More...
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Data Fields

 $ExtractData = 0
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $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 //.

module for analyzing PhotoCD (PCD) Image files

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 28 of file Pcd.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Graphic\Pcd::analyze ( )

Analyze from file pointer.

Reimplemented from GetId3\Handler\BaseHandler.

Definition at line 39 of file Pcd.php.

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

References $info, $x, $y, GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), and GetId3\Module\Graphic\Pcd\YCbCr2RGB().

+ Here is the call graph for this function:

◆ YCbCr2RGB()

GetId3\Module\Graphic\Pcd::YCbCr2RGB (   $Y,
  $Cb,
  $Cr 
)

@staticvar array $YCbCr_constants

Parameters
type$Y
type$Cb
type$Cr
Returns
type

Definition at line 125 of file Pcd.php.

126 {
127 static $YCbCr_constants = array();
128 if (empty($YCbCr_constants)) {
129 $YCbCr_constants['red']['Y'] = 0.0054980 * 256;
130 $YCbCr_constants['red']['Cb'] = 0.0000000 * 256;
131 $YCbCr_constants['red']['Cr'] = 0.0051681 * 256;
132 $YCbCr_constants['green']['Y'] = 0.0054980 * 256;
133 $YCbCr_constants['green']['Cb'] = -0.0015446 * 256;
134 $YCbCr_constants['green']['Cr'] = -0.0026325 * 256;
135 $YCbCr_constants['blue']['Y'] = 0.0054980 * 256;
136 $YCbCr_constants['blue']['Cb'] = 0.0079533 * 256;
137 $YCbCr_constants['blue']['Cr'] = 0.0000000 * 256;
138 }
139
140 $RGBcolor = array('red'=>0, 'green'=>0, 'blue'=>0);
141 foreach ($RGBcolor as $rgbname => $dummy) {
142 $RGBcolor[$rgbname] = max(0,
143 min(255,
144 intval(
145 round(
146 ($YCbCr_constants[$rgbname]['Y'] * $Y) +
147 ($YCbCr_constants[$rgbname]['Cb'] * ($Cb - 156)) +
148 ($YCbCr_constants[$rgbname]['Cr'] * ($Cr - 137))
149 )
150 )
151 )
152 );
153 }
154
155 return (($RGBcolor['red'] * 65536) + ($RGBcolor['green'] * 256) + $RGBcolor['blue']);
156 }

Referenced by GetId3\Module\Graphic\Pcd\analyze().

+ Here is the caller graph for this function:

Field Documentation

◆ $ExtractData

GetId3\Module\Graphic\Pcd::$ExtractData = 0

Definition at line 34 of file Pcd.php.


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