Binds the width, height, bit depth and number of channels from stored internal features.
Parameters
$target_item_id
intrequired- Id of the item whose features will be bound.
$tile_depth
intrequired- Maximum recursion to search within tile-parent relations.
Source
private function get_item_features( $target_item_id, $tile_depth ) {
foreach ( $this->props as $prop ) {
if ( $prop->item_id != $target_item_id ) {
continue;
}
// Retrieve the width and height of the primary item if not already done.
if ( $target_item_id == $this->primary_item_id &&
( $this->primary_item_features['width'] == UNDEFINED ||
$this->primary_item_features['height'] == UNDEFINED ) ) {
foreach ( $this->dim_props as $dim_prop ) {
if ( $dim_prop->property_index != $prop->property_index ) {
continue;
}
$this->primary_item_features['width'] = $dim_prop->width;
$this->primary_item_features['height'] = $dim_prop->height;
if ( $this->primary_item_features['bit_depth'] != UNDEFINED &&
$this->primary_item_features['num_channels'] != UNDEFINED ) {
return FOUND;
}
break;
}
}
// Retrieve the bit depth and number of channels of the target item if not
// already done.
if ( $this->primary_item_features['bit_depth'] == UNDEFINED ||
$this->primary_item_features['num_channels'] == UNDEFINED ) {
foreach ( $this->chan_props as $chan_prop ) {
if ( $chan_prop->property_index != $prop->property_index ) {
continue;
}
$this->primary_item_features['bit_depth'] = $chan_prop->bit_depth;
$this->primary_item_features['num_channels'] = $chan_prop->num_channels;
if ( $this->primary_item_features['width'] != UNDEFINED &&
$this->primary_item_features['height'] != UNDEFINED ) {
return FOUND;
}
break;
}
}
}
// Check for the bit_depth and num_channels in a tile if not yet found.
if ( $tile_depth < 3 ) {
foreach ( $this->tiles as $tile ) {
if ( $tile->parent_item_id != $target_item_id ) {
continue;
}
$status = $this->get_item_features( $tile->tile_item_id, $tile_depth + 1 );
if ( $status != NOT_FOUND ) {
return $status;
}
}
}
return NOT_FOUND;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.