Example #1
0
 public function divineFileFormat($ps_filepath)
 {
     # is it a camera raw image?
     if (caMediaPluginDcrawInstalled($this->ops_dcraw_path)) {
         exec($this->ops_dcraw_path . " -i " . caEscapeShellArg($ps_filepath) . " 2> /dev/null", $va_output, $vn_return);
         if ($vn_return == 0) {
             if (!preg_match("/^Cannot decode/", $va_output[0]) && !preg_match("/Master/i", $va_output[0])) {
                 return 'image/x-dcraw';
             }
         }
     }
     try {
         if ($ps_filepath != '' && ($r_handle = new Gmagick($ps_filepath))) {
             $this->setResourceLimits($r_handle);
             $mimetype = $this->_getMagickImageMimeType($r_handle);
             if ($mimetype && $this->info["IMPORT"][$mimetype]) {
                 return $mimetype;
             } else {
                 return '';
             }
         }
     } catch (Exception $e) {
         # is it a tilepic?
         $tp = new TilepicParser();
         if ($tp->isTilepic($ps_filepath)) {
             return 'image/tilepic';
         } else {
             # file format is not supported by this plug-in
             return '';
         }
     }
 }
Example #2
0
 public function divineFileFormat($filepath)
 {
     if (!$filepath || !file_exists($filepath)) {
         return '';
     }
     if ($va_info = @getimagesize($filepath)) {
         switch ($va_info[2]) {
             case IMAGETYPE_GIF:
                 return "image/gif";
                 break;
             case IMAGETYPE_JPEG:
                 return "image/jpeg";
                 break;
             case IMAGETYPE_PNG:
                 return "image/png";
                 break;
         }
         return '';
     } else {
         $tp = new TilepicParser();
         $tp->useLibrary(LIBRARY_GD);
         if ($tp->isTilepic($filepath)) {
             return "image/tilepic";
         } else {
             # file format is not supported by this plug-in
             return '';
         }
     }
 }
Example #3
0
 public function divineFileFormat($filepath)
 {
     if (!strpos($filepath, ':') || caGetOSFamily() == OS_WIN32) {
         // ImageMagick bails when a colon is in the file name... catch it here
         $vs_mimetype = $this->_graphicsMagickIdentify($filepath);
         return $vs_mimetype ? $vs_mimetype : '';
     } else {
         $this->postError(1610, _t("Filenames with colons (:) are not allowed"), "WLPlugImageMagick->divineFileFormat()");
         return false;
     }
     # is it a tilepic?
     $tp = new TilepicParser();
     if ($tp->isTilepic($filepath)) {
         return 'image/tilepic';
     } else {
         # file format is not supported by this plug-in
         return '';
     }
 }