/** * Read from a file * * @deprecated Use img.io.MetaDataReader instead * @param io.File file * @param var default default void what should be returned in case no data is found * @return img.util.IptcData * @throws lang.FormatException in case malformed meta data is encountered * @throws lang.ElementNotFoundException in case no meta data is available * @throws img.ImagingException in case reading meta data fails */ public static function fromFile(File $file) { if (FALSE === getimagesize($file->getURI(), $info)) { $e = new ImagingException('Cannot read image information from ' . $file->getURI()); xp::gc(__FILE__); throw $e; } if (!isset($info['APP13'])) { if (func_num_args() > 1) { return func_get_arg(1); } throw new ElementNotFoundException('Cannot get IPTC information from ' . $file->getURI() . ' (no APP13 marker)'); } if (!($iptc = iptcparse($info['APP13']))) { throw new FormatException('Cannot parse IPTC information from ' . $file->getURI()); } // Parse creation date if (3 == sscanf(@$iptc['2#055'][0], '%4d%2d%d', $year, $month, $day)) { $created = Date::create($year, $month, $day, 0, 0, 0); } else { $created = NULL; } with($i = new self()); $i->setTitle(@$iptc['2#005'][0]); $i->setUrgency(@$iptc['2#010'][0]); $i->setCategory(@$iptc['2#015'][0]); $i->setSupplementalCategories(@$iptc['2#020']); $i->setKeywords(@$iptc['2#025']); $i->setSpecialInstructions(@$iptc['2#040'][0]); $i->setDateCreated($created); $i->setAuthor(@$iptc['2#080'][0]); $i->setAuthorPosition(@$iptc['2#085'][0]); $i->setCity(@$iptc['2#090'][0]); $i->setState(@$iptc['2#095'][0]); $i->setCountry(@$iptc['2#101'][0]); $i->setOriginalTransmissionReference(@$iptc['2#103'][0]); $i->setHeadline(@$iptc['2#105'][0]); $i->setCredit(@$iptc['2#110'][0]); $i->setSource(@$iptc['2#115'][0]); $i->setCopyrightNotice(@$iptc['2#116'][0]); $i->setCaption(@$iptc['2#120'][0]); $i->setWriter(@$iptc['2#122'][0]); return $i; }