public function read($filepath, $mimetype = "") { if ($mimetype == 'image/tilepic') { # # Read in Tilepic format image # $this->handle = new TilepicParser($filepath); $this->handle->useLibrary(LIBRARY_GD); if (!$this->handle->error) { $this->filepath = $filepath; foreach ($this->handle->properties as $k => $v) { if (isset($this->properties[$k])) { $this->properties[$k] = $v; } } $this->properties["mimetype"] = "image/tilepic"; $this->properties["typename"] = "Tilepic"; return true; } else { $this->postError(1610, $this->handle->error, "WLPlugGD->read()"); return false; } } else { $this->handle = ""; $this->filepath = ""; $this->metadata = array(); $va_info = @getimagesize($filepath); switch ($va_info[2]) { case IMAGETYPE_GIF: $this->handle = imagecreatefromgif($filepath); $vs_mimetype = "image/gif"; $vs_typename = "GIF"; break; case IMAGETYPE_JPEG: if (function_exists('exif_read_data') && !$this->opo_config->get('dont_use_exif_read_data')) { $this->metadata["EXIF"] = $va_exif = caSanitizeArray(@exif_read_data($filepath, 'EXIF', true, false)); // // Rotate incoming image as needed // if (is_array($va_exif)) { if (isset($va_exif['IFD0']['Orientation'])) { $vn_orientation = $va_exif['IFD0']['Orientation']; switch ($vn_orientation) { case 3: $this->handle = imagecreatefromjpeg($filepath); $this->handle = $this->rotateImage($this->handle, -180); break; case 6: $this->handle = imagecreatefromjpeg($filepath); $this->handle = $this->rotateImage($this->handle, -90); $va_tmp = $va_info; $va_info[0] = $va_tmp[1]; $va_info[1] = $va_tmp[0]; break; case 8: $this->handle = imagecreatefromjpeg($filepath); $this->handle = $this->rotateImage($this->handle, 90); $va_tmp = $va_info; $va_info[0] = $va_tmp[1]; $va_info[1] = $va_tmp[0]; break; } } } } if (!$this->handle) { $this->handle = imagecreatefromjpeg($filepath); } $vs_mimetype = "image/jpeg"; $vs_typename = "JPEG"; $o_xmp = new XMPParser(); if ($o_xmp->parse($filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = $va_xmp_metadata; } } break; case IMAGETYPE_PNG: $this->handle = imagecreatefrompng($filepath); $vs_mimetype = "image/png"; $vs_typename = "PNG"; break; default: return false; break; } if ($this->handle) { $this->filepath = $filepath; # load image properties $this->properties["width"] = $va_info[0]; $this->properties["height"] = $va_info[1]; $this->properties["mimetype"] = $vs_mimetype; $this->properties["typename"] = $vs_typename; $this->properties["filesize"] = @filesize($filepath); return true; } else { # plug-in can't handle format return false; } } }
private function _graphicsMagickGetMetadata($ps_filepath) { $va_metadata = array(); /* EXIF metadata */ if (function_exists('exif_read_data') && !$this->opo_config->get('dont_use_exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } // if the builtin EXIF extraction is not used or failed for some reason, try ExifTool if (!isset($va_metadata['EXIF']) || !is_array($va_metadata['EXIF'])) { if (caExifToolInstalled()) { $va_metadata['EXIF'] = caExtractMetadataWithExifTool($ps_filepath, true); } } // else try GraphicsMagick if (!isset($va_metadata['EXIF']) || !is_array($va_metadata['EXIF'])) { exec($this->ops_graphicsmagick_path . ' identify -format "%[EXIF:*]" ' . caEscapeShellArg($ps_filepath) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return); if (is_array($va_output) && sizeof($va_output) > 1) { foreach ($va_output as $vs_output_line) { $va_tmp = explode('=', $vs_output_line); // format is "Make=NIKON CORPORATION" if (isset($va_tmp[0]) && isset($va_tmp[1])) { $va_metadata['EXIF'][$va_tmp[0]] = $va_tmp[1]; } } } $va_output = array(); } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = array(); foreach ($va_xmp_metadata as $vs_xmp_tag => $va_xmp_values) { $va_metadata['XMP'][$vs_xmp_tag] = join('; ', $va_xmp_values); } } } /* IPTC metadata */ $vs_iptc_file = tempnam(caGetTempDirPath(), 'gmiptc'); @rename($vs_iptc_file, $vs_iptc_file . '.iptc'); // GM uses the file extension to figure out what we want $vs_iptc_file .= '.iptc'; exec($this->ops_graphicsmagick_path . " convert " . caEscapeShellArg($ps_filepath) . " " . caEscapeShellArg($vs_iptc_file) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return); $vs_iptc_data = file_get_contents($vs_iptc_file); @unlink($vs_iptc_file); $va_iptc_raw = iptcparse($vs_iptc_data); $va_iptc_tags = array('2#004' => 'Genre', '2#005' => 'DocumentTitle', '2#010' => 'Urgency', '2#015' => 'Category', '2#020' => 'Subcategories', '2#025' => 'Keywords', '2#040' => 'SpecialInstructions', '2#055' => 'CreationDate', '2#060' => 'TimeCreated', '2#080' => 'AuthorByline', '2#085' => 'AuthorTitle', '2#090' => 'City', '2#095' => 'State', '2#100' => 'CountryCode', '2#101' => 'Country', '2#103' => 'OTR', '2#105' => 'Headline', '2#110' => 'Credit', '2#115' => 'PhotoSource', '2#116' => 'Copyright', '2#120' => 'Caption', '2#122' => 'CaptionWriter'); $va_iptc = array(); if (is_array($va_iptc_raw)) { foreach ($va_iptc_raw as $vs_iptc_tag => $va_iptc_tag_data) { if (isset($va_iptc_tags[$vs_iptc_tag])) { $va_iptc[$va_iptc_tags[$vs_iptc_tag]] = join('; ', $va_iptc_tag_data); } } } if (sizeof($va_iptc)) { $va_metadata['IPTC'] = $va_iptc; } /* DPX metadata */ exec($this->ops_graphicsmagick_path . " identify -format '%[DPX:*]' " . caEscapeShellArg($ps_filepath) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return); if ($va_output[0]) { $va_metadata['DPX'] = $va_output; } return $va_metadata; }
private function _gmagickRead($ps_filepath) { try { $handle = new Gmagick($ps_filepath); $this->setResourceLimits($handle); $handle->setimageindex(0); // force use of first image in multi-page TIFF $this->handle = $handle; $this->filepath = $ps_filepath; $this->metadata = array(); // handle metadata /* EXIF */ if (function_exists('exif_read_data') && !$this->opo_config->get('dont_use_exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } // if the builtin EXIF extraction is not used or failed for some reason, try ExifTool if (!isset($va_metadata['EXIF']) || !is_array($va_metadata['EXIF'])) { if (caExifToolInstalled()) { $va_metadata['EXIF'] = caExtractMetadataWithExifTool($ps_filepath, true); } } // Rotate incoming image as needed if (isset($va_metadata['EXIF']['IFD0']['Orientation'])) { $vn_orientation = $va_metadata['EXIF']['IFD0']['Orientation']; $vs_tmp_basename = tempnam(caGetTempDirPath(), 'ca_image_tmp'); $vb_is_rotated = false; switch ($vn_orientation) { case 3: $this->handle->rotateimage("#FFFFFF", 180); unset($va_metadata['EXIF']['IFD0']['Orientation']); $vb_is_rotated = true; break; case 6: $this->handle->rotateimage("#FFFFFF", 90); unset($va_metadata['EXIF']['IFD0']['Orientation']); $vb_is_rotated = true; break; case 8: $this->handle->rotateimage("#FFFFFF", -90); unset($va_metadata['EXIF']['IFD0']['Orientation']); $vb_is_rotated = true; break; } if ($vb_is_rotated) { if ($this->handle->writeimage($vs_tmp_basename)) { $va_tmp = $this->handle->getimagegeometry(); $this->properties["faces"] = $this->opa_faces = caDetectFaces($vs_tmp_basename, $va_tmp['width'], $va_tmp['height']); } @unlink($vs_tmp_basename); } } // get XMP $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = array(); foreach ($va_xmp_metadata as $vs_xmp_tag => $va_xmp_values) { $va_metadata['XMP'][$vs_xmp_tag] = join('; ', $va_xmp_values); } } } // try to get IPTC and DPX with GraphicsMagick, if available if (caMediaPluginGraphicsMagickInstalled()) { /* IPTC metadata */ $vs_iptc_file = tempnam(caGetTempDirPath(), 'gmiptc'); @rename($vs_iptc_file, $vs_iptc_file . '.iptc'); // GM uses the file extension to figure out what we want $vs_iptc_file .= '.iptc'; exec($this->ops_graphicsmagick_path . " convert " . caEscapeShellArg($ps_filepath) . " " . caEscapeShellArg($vs_iptc_file) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return); $vs_iptc_data = file_get_contents($vs_iptc_file); @unlink($vs_iptc_file); $va_iptc_raw = iptcparse($vs_iptc_data); $va_iptc_tags = array('2#004' => 'Genre', '2#005' => 'DocumentTitle', '2#010' => 'Urgency', '2#015' => 'Category', '2#020' => 'Subcategories', '2#025' => 'Keywords', '2#040' => 'SpecialInstructions', '2#055' => 'CreationDate', '2#060' => 'TimeCreated', '2#080' => 'AuthorByline', '2#085' => 'AuthorTitle', '2#090' => 'City', '2#095' => 'State', '2#100' => 'CountryCode', '2#101' => 'Country', '2#103' => 'OTR', '2#105' => 'Headline', '2#110' => 'Credit', '2#115' => 'PhotoSource', '2#116' => 'Copyright', '2#120' => 'Caption', '2#122' => 'CaptionWriter'); $va_iptc = array(); if (is_array($va_iptc_raw)) { foreach ($va_iptc_raw as $vs_iptc_tag => $va_iptc_tag_data) { if (isset($va_iptc_tags[$vs_iptc_tag])) { $va_iptc[$va_iptc_tags[$vs_iptc_tag]] = join('; ', $va_iptc_tag_data); } } } if (sizeof($va_iptc)) { $va_metadata['IPTC'] = $va_iptc; } /* DPX metadata */ exec($this->ops_graphicsmagick_path . " identify -format '%[DPX:*]' " . caEscapeShellArg($ps_filepath) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return); if ($va_output[0]) { $va_metadata['DPX'] = $va_output; } } $this->metadata = $va_metadata; return $handle; } catch (Exception $e) { $this->postError(1610, _t("Could not read image file"), "WLPlugGmagick->read()"); return false; // gmagick couldn't read file, presumably } }
public function read($ps_filepath, $mimetype = "") { if (!($this->handle && ${$ps_filepath} === $this->filepath)) { if ($mimetype == 'image/tilepic') { # # Read in Tilepic format image # $this->handle = new TilepicParser($ps_filepath); if (!$this->handle->error) { $this->filepath = $ps_filepath; foreach ($this->handle->properties as $k => $v) { if (isset($this->properties[$k])) { $this->properties[$k] = $v; } } $this->properties["mimetype"] = "image/tilepic"; $this->properties["typename"] = "Tilepic"; return 1; } else { $this->postError(1610, $this->handle->error, "WLPlugImagick->read()"); return false; } } else { $this->handle = ""; $this->filepath = ""; $handle = new Imagick(); if ($mimetype == 'image/x-dcraw') { if ($this->filepath_conv) { @unlink($this->filepath_conv); } if (!caMediaPluginDcrawInstalled($this->ops_dcraw_path)) { $this->postError(1610, _t("Could not convert Camera RAW format file because conversion tool (dcraw) is not installed"), "WLPlugImagick->read()"); return false; } $vs_tmp_name = tempnam(caGetTempDirPath(), "rawtmp"); if (!copy($ps_filepath, $vs_tmp_name)) { $this->postError(1610, _t("Could not copy Camera RAW file to temporary directory"), "WLPlugImagick->read()"); return false; } exec($this->ops_dcraw_path . " -T " . caEscapeShellArg($vs_tmp_name), $va_output, $vn_return); if ($vn_return != 0) { $this->postError(1610, _t("Camera RAW file conversion failed: %1", $vn_return), "WLPlugImagick->read()"); return false; } if (!(file_exists($vs_tmp_name . '.tiff') && filesize($vs_tmp_name . '.tiff') > 0)) { $this->postError(1610, _t("Translation from Camera RAW to TIFF failed"), "WLPlugImagick->read()"); return false; } $ps_filepath = $this->filepath_conv = $vs_tmp_name . '.tiff'; @unlink($vs_tmp_name); } if ($handle->readImage($ps_filepath)) { $this->handle = $handle; $this->filepath = $ps_filepath; $va_raw_metadata = $this->handle->getImageProperties(); $this->metadata = array(); foreach ($va_raw_metadata as $vs_tag => $vs_value) { if (sizeof($va_tmp = explode(':', $vs_tag)) > 1) { $vs_type = strtoupper($va_tmp[0]); $vs_tag = $va_tmp[1]; } else { $vs_type = 'GENERIC'; } if ($vs_type == 'EXIF') { continue; } $this->metadata[$vs_type][$vs_tag] = $vs_value; } // exif if (function_exists('exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { // // Rotate incoming image as needed // if (isset($va_exif['IFD0']['Orientation'])) { $vn_orientation = $va_exif['IFD0']['Orientation']; $vs_tmp_basename = tempnam(caGetTempDirPath(), 'ca_image_tmp'); $vb_is_rotated = false; switch ($vn_orientation) { case 3: $this->handle->rotateImage("#FFFFFF", 180); unset($va_exif['IFD0']['Orientation']); $vb_is_rotated = true; break; case 6: $this->handle->rotateImage("#FFFFFF", 90); unset($va_exif['IFD0']['Orientation']); $vb_is_rotated = true; break; case 8: $this->handle->rotateImage("#FFFFFF", -90); unset($va_exif['IFD0']['Orientation']); $vb_is_rotated = true; break; } if ($vb_is_rotated) { if ($this->handle->writeImage($vs_tmp_basename)) { $va_tmp = $this->handle->getImageGeometry(); $this->properties["faces"] = $this->opa_faces = caDetectFaces($vs_tmp_basename, $va_tmp['width'], $va_tmp['height']); } @unlink($vs_tmp_basename); } } $this->metadata['EXIF'] = $va_exif; } } // XMP $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $this->metadata['XMP'] = $va_xmp_metadata; } } # load image properties $va_tmp = $this->handle->getImageGeometry(); $this->properties["width"] = $va_tmp['width']; $this->properties["height"] = $va_tmp['height']; $this->properties["quality"] = ""; $this->properties["filesize"] = $this->handle->getImageLength(); $this->properties["bitdepth"] = $this->handle->getImageDepth(); $this->properties["resolution"] = $this->handle->getImageResolution(); $this->properties["colorspace"] = $this->_getColorspaceAsString($this->handle->getImageColorspace()); // force all images to true color (takes care of GIF transparency for one thing...) $this->handle->setImageType(imagick::IMGTYPE_TRUECOLOR); if (!$this->handle->setImageColorspace(imagick::COLORSPACE_RGB)) { $this->postError(1610, _t("Error during RGB colorspace transformation operation"), "WLPlugImagick->read()"); return false; } if (!$this->properties["faces"]) { $this->properties["faces"] = $this->opa_faces = caDetectFaces($ps_filepath, $va_tmp['width'], $va_tmp['height']); } $this->properties["mimetype"] = $this->_getMagickImageMimeType($this->handle); $this->properties["typename"] = $this->handle->getImageFormat(); $this->ohandle = $this->handle->clone(); return 1; } else { $this->postError(1610, _t("Could not read image file"), "WLPlugImagick->read()"); return false; } } } else { # image already loaded by previous call (probably divineFileFormat()) return 1; } }
private function _CoreImageGetMetadata($ps_filepath) { if (caMediaPluginCoreImageInstalled($this->ops_CoreImage_path)) { $va_metadata = array(); if (function_exists('exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = $va_xmp_metadata; } } return $va_metadata; } return null; }
/** * Embed XMP metadata into representation media. Embedding is performed on a copy of the representation media and placed * into the system tmp directory. The original media is never modified. * * @param BaseModel $po_object ca_objects instance to pull metadata from for embedding * @param BaseModel $po_representation ca_object_representations instance to pull metadata from for embedding * @param string $ps_version Version of media to embed into. If omitted "original" version is used. * @return string Path to copy of media with embedded metadata. False is returned in the embedding failed. */ function caEmbedMetadataIntoRepresentation($po_object, $po_representation, $ps_version = "original") { if (!($vs_media_metadata_config = $po_representation->getAppConfig()->get('media_metadata'))) { return false; } $o_metadata_config = Configuration::load($vs_media_metadata_config); $vs_mimetype = $po_representation->getMediaInfo('media', $ps_version, 'MIMETYPE'); if (!in_array($vs_mimetype, array('image/jpeg'))) { return false; } // Don't try to embed in files other than JPEGs $vs_filepath = $po_representation->getMediaPath('media', $ps_version); if (!file_exists($vs_filepath)) { return false; } $va_mappings = $o_metadata_config->getAssoc('export_mappings'); $o_xmp = new XMPParser(); copy($vs_filepath, $vs_tmp_filepath = caGetTempDirPath() . "/" . time() . md5($vs_filepath)); $o_xmp->parse($vs_tmp_filepath); $o_xmp->initMetadata(); if (is_object($po_object) && isset($va_mappings['ca_objects']) && is_array($va_mappings['ca_objects'])) { $va_mapping = $va_mappings['ca_objects']; $vs_type = $po_object->getTypeCode(); if (isset($va_mapping[$vs_type]) && is_array($va_mapping[$vs_type])) { $va_mapping = $va_mapping[$vs_type]; } else { if (isset($va_mapping['__default__']) && is_array($va_mapping['__default__'])) { $va_mapping = $va_mapping['__default__']; } else { return null; } } if (is_array($va_mapping)) { foreach ($va_mapping as $vs_xmp => $va_ca) { $va_tmp = explode(':', $vs_xmp); if (sizeof($va_tmp) > 1) { $vs_xmp = $va_tmp[1]; } foreach ($va_ca as $vs_ca => $va_opts) { if (preg_match('!^static:!', $vs_ca)) { $vs_val = preg_replace('!^static:!', '', $vs_ca); } else { $vs_val = $po_object->get($vs_ca, $va_opts); } if ($vs_val) { $o_xmp->set($vs_xmp, $vs_val); } } } } } if (is_object($po_representation) && isset($va_mappings['ca_object_representations']) && is_array($va_mappings['ca_object_representations'])) { $va_mapping = $va_mappings['ca_object_representations']; $vs_type = $po_representation->getTypeCode(); if (isset($va_mapping[$vs_type]) && is_array($va_mapping[$vs_type])) { $va_mapping = $va_mapping[$vs_type]; } else { if (isset($va_mapping['__default__']) && is_array($va_mapping['__default__'])) { $va_mapping = $va_mapping['__default__']; } else { return null; } } if (is_array($va_mapping)) { foreach ($va_mapping as $vs_xmp => $va_ca) { $va_tmp = explode(':', $vs_xmp); if (sizeof($va_tmp) > 1) { $vs_xmp = $va_tmp[1]; } foreach ($va_ca as $vs_ca => $va_opts) { if (preg_match('!^static:!', $vs_ca)) { $vs_val = preg_replace('!^static:!', '', $vs_ca); } else { $vs_val = $po_representation->get($vs_ca, $va_opts); } if ($vs_val) { $o_xmp->set($vs_xmp, $vs_val); } } } } } $o_xmp->write(); return $vs_tmp_filepath; }
private function _graphicsMagickGetMetadata($ps_filepath) { $va_metadata = array(); /* EXIF metadata */ if (function_exists('exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = array(); foreach ($va_xmp_metadata as $vs_xmp_tag => $va_xmp_values) { $va_metadata['XMP'][$vs_xmp_tag] = join('; ', $va_xmp_values); } } } /* IPTC metadata */ $vs_iptc_file = tempnam(caGetTempDirPath(), 'gmiptc'); @rename($vs_iptc_file, $vs_iptc_file . '.iptc'); // GM uses the file extension to figure out what we want $vs_iptc_file .= '.iptc'; exec($this->ops_graphicsmagick_path . " convert " . caEscapeShellArg($ps_filepath) . " " . caEscapeShellArg($vs_iptc_file), $va_output, $vn_return); $vs_iptc_data = file_get_contents($vs_iptc_file); @unlink($vs_iptc_file); $va_iptc_raw = iptcparse($vs_iptc_data); $va_iptc_tags = array('2#004' => 'Genre', '2#005' => 'DocumentTitle', '2#010' => 'Urgency', '2#015' => 'Category', '2#020' => 'Subcategories', '2#025' => 'Keywords', '2#040' => 'SpecialInstructions', '2#055' => 'CreationDate', '2#060' => 'TimeCreated', '2#080' => 'AuthorByline', '2#085' => 'AuthorTitle', '2#090' => 'City', '2#095' => 'State', '2#100' => 'CountryCode', '2#101' => 'Country', '2#103' => 'OTR', '2#105' => 'Headline', '2#110' => 'Credit', '2#115' => 'PhotoSource', '2#116' => 'Copyright', '2#120' => 'Caption', '2#122' => 'CaptionWriter'); $va_iptc = array(); if (is_array($va_iptc_raw)) { foreach ($va_iptc_raw as $vs_iptc_tag => $va_iptc_tag_data) { if (isset($va_iptc_tags[$vs_iptc_tag])) { $va_iptc[$va_iptc_tags[$vs_iptc_tag]] = join('; ', $va_iptc_tag_data); } } } if (sizeof($va_iptc)) { $va_metadata['IPTC'] = $va_iptc; } /* DPX metadata */ exec($this->ops_graphicsmagick_path . " identify -format '%[DPX:*]' " . caEscapeShellArg($ps_filepath), $va_output, $vn_return); if ($va_output[0]) { $va_metadata['DPX'] = $va_output; } return $va_metadata; }
private function _imageMagickGetMetadata($ps_filepath) { if (caMediaPluginImageMagickInstalled($this->ops_imagemagick_path)) { $va_metadata = array(); if (function_exists('exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = $va_xmp_metadata; } } exec($this->ops_imagemagick_path . "/identify -format '%[DPX:*]' " . caEscapeShellArg($ps_filepath), $va_output, $vn_return); if ($va_output[0]) { $va_metadata['DPX'] = $va_output; } $va_iptc_tags = array('credit' => '2:110', 'byline' => '2:080', 'date_created' => '2:055', 'time_created' => '2:060', 'caption' => '2:120', 'copyright' => '2:116', 'title' => '2:005', 'genre' => '2:004', 'urgency' => '2:010', 'category' => '2:015', 'supplemental category' => '2:020', 'keywords' => '2:025', 'special_instructions' => '2:040', 'byline' => '2:080', 'bylinetitle' => '2:085', 'city' => '2:090', 'location' => '2:092', 'province' => '2:095', 'countrycode' => '2:100', 'countryname' => '2:101', 'headline' => '2:105', 'credit' => '2:110', 'source' => '2:115', 'description writer' => '2:122'); $va_iptc = array(); foreach ($va_iptc_tags as $vs_tag_name => $vs_tag_code) { $va_output = array(); exec($this->ops_imagemagick_path . "/identify -format '%[IPTC:" . $vs_tag_code . "]' " . caEscapeShellArg($ps_filepath), $va_output, $vn_return); if ($va_output[0]) { $va_iptc[str_replace(":", ",", $vs_tag_code) . ' [' . $vs_tag_name . ']'] = $va_output[0]; } } if (sizeof($va_iptc)) { $va_metadata['IPTC'] = $va_iptc; } return $va_metadata; } return null; }
private function _graphicsMagickGetMetadata($ps_filepath) { $va_metadata = array(); if (function_exists('exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = $va_xmp_metadata; } } // GM doesn't seem to support DPX or IPTC metadata extraction :-( return $va_metadata; }
private function _CoreImageGetMetadata($ps_filepath) { if (caMediaPluginCoreImageInstalled($this->ops_CoreImage_path)) { $va_metadata = array(); if (function_exists('exif_read_data') && !$this->opo_config->get('dont_use_exif_read_data')) { if (is_array($va_exif = caSanitizeArray(@exif_read_data($ps_filepath, 'EXIF', true, false)))) { $va_metadata['EXIF'] = $va_exif; } } // if the builtin EXIF extraction is not used or failed for some reason, try ExifTool if (!isset($va_metadata['EXIF']) || !is_array($va_metadata['EXIF'])) { if (caExifToolInstalled()) { $va_metadata['EXIF'] = caExtractMetadataWithExifTool($ps_filepath, true); } } $o_xmp = new XMPParser(); if ($o_xmp->parse($ps_filepath)) { if (is_array($va_xmp_metadata = $o_xmp->getMetadata()) && sizeof($va_xmp_metadata)) { $va_metadata['XMP'] = $va_xmp_metadata; } } return $va_metadata; } return null; }