예제 #1
0
 static function processImportedImage($filePath)
 {
     $fullPath = $filePath;
     if (!igUploadHelper::checkExtension($fullPath, false)) {
         return false;
     }
     if (!igUploadHelper::checkIsImage($fullPath, false)) {
         return false;
     }
     $slash = strrpos($fullPath, DIRECTORY_SEPARATOR) + 1;
     $filename = substr($fullPath, $slash);
     $filename = igUploadHelper::replaceSpecial($filename);
     //get the folder path
     $increment = igFileHelper::getFileIncrement('igallery_img');
     $folderName = igFileHelper::getFolderName($increment);
     igFileHelper::makeFolder(IG_ORIG_PATH . '/' . $folderName);
     $destFolderPath = IG_ORIG_PATH . '/' . $folderName;
     //make the filename
     $destFile = igFileHelper::addIncrement($filename, $increment);
     $destFile = igFileHelper::checkUniqueName($destFolderPath, $destFile);
     $destPath = $destFolderPath . '/' . $destFile;
     $imageinfo = getimagesize($fullPath);
     $params = JComponentHelper::getParams('com_igallery');
     $maxServerWidth = $params->get('server_max_width', 2100);
     $maxServerHeight = $params->get('server_max_height', 1600);
     if ($imageinfo[0] > $maxServerWidth || $imageinfo[1] > $maxServerHeight) {
         if (!igFileHelper::makeImage($fullPath, $destPath, $maxServerWidth, $maxServerHeight, 95, false)) {
             return false;
         }
     } else {
         if (!JFile::copy($fullPath, $destPath)) {
             igFileHelper::raiseError($fullPath . ' -> ' . $destPath . ' ' . JText::_('Error Moving File To Directory'), false);
             return false;
         }
     }
     $fileData = array();
     $fileData['filename'] = $destFile;
     if ($params->get('import_exif_data', 0) == 1) {
         $fileData['exif_des'] = igFileHelper::getExifData($fullPath);
     }
     if ($params->get('import_iptc_data', 0) == 1) {
         $fileData['iptc_des'] = igFileHelper::getIptcData($fullPath);
     }
     if ($params->get('import_iptc_tags', 0) == 1) {
         $fileData['iptc_tags'] = igFileHelper::getIptcTags($fullPath);
     }
     return $fileData;
 }