/*!
Reads all image aliases from the INI file 'image.ini'
and appends them to the image system.
\param $iniFile The INI file to read from or if \c false use 'image.ini'
335436
function readImageAliasesFromINI( $iniFile = false )
    {
        if ( !$iniFile )
            $iniFile = 'image.ini';
        $ini = eZINI::instance( $iniFile );
        if ( !$ini )
            return false;
        $aliasNames = $ini->variable( 'AliasSettings', 'AliasList' );
        foreach ( $aliasNames as $aliasName )
        {
            $alias = $this->createAliasFromINI( $aliasName );
            if ( $alias )
            {
                $this->appendImageAlias( $alias );
            }
            else
                eZDebug::writeWarning( "Failed reading Image Alias $aliasName from $iniFile", __METHOD__ );
        }
        $aliasName = 'original';
        if ( !in_array( $aliasName, $aliasNames ) )
        {
            $ini = eZINI::instance( 'image.ini' );
            if ( $ini->hasGroup( $aliasName ) )
            {
                $alias = $this->createAliasFromINI( $aliasName );
                if ( $alias )
                {
                    $alias['reference'] = false;
                    $this->appendImageAlias( $alias );
                }
                else
                {
                    eZDebug::writeWarning( "Failed reading Image Alias $aliasName from $iniFile", __METHOD__ );
                }
            }
        }
    }
1360111
protected function innerLoad($envFile)
    {
        $this->lastEnvFile = $envFile;
        
        if(!is_readable($this->lastEnvFile) || !is_file($this->lastEnvFile)) {
            throw new InvalidArgumentException(sprintf('Phpenv: [%s] file not found or no readable', $this->lastEnvFile));
        }
        $this->envFiles[$envFile] = $envFile;
        
        $systemAutoDetectLine = ini_get('auto_detect_line_endings');
        ini_set('auto_detect_line_endings', '1');
        $rows = file($this->lastEnvFile, FILE_SKIP_EMPTY_LINES|FILE_IGNORE_NEW_LINES);
        ini_set('auto_detect_line_endings', $systemAutoDetectLine);
        
        foreach ($rows as $row) {
            $data = $this->filter($row);
            if($data != null) {
                list($key, $val) = $data;
                $val = $this->handleSemanticsVar($val);
                $this->setEnv($key, $val);
            }
        }
    }
288050
public static function ini()
    {
        $files = glob(static::path().'*.php');

        foreach ($files as $file) {
            $table = need($file);

            foreach ($table as $key => $value) {
                $file = static::getFileName($file);

                self::$links[$file][$key] = $value;
            }
        }
    }
296431
public static function png_to_gif_by_imagemagick($theFile) {
		if ($GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif']
				&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']
				&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']
				&& strtolower(substr($theFile, -4, 4)) == '.png'
				&& @is_file($theFile)) { // IM
			$newFile = substr($theFile, 0, -4) . '.gif';
			$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
			t3lib_utility_Command::exec($cmd);
			$theFile = $newFile;
			if (@is_file($newFile)) {
				self::fixPermissions($newFile);
			}
				// unlink old file?? May be bad idea because TYPO3 would then recreate the file every time as
				// TYPO3 thinks the file is not generated because it's missing!! So do not unlink $theFile here!!
		}
		return $theFile;
	}
686243
function loadGIF( $storedPath, $storedFile )
    {
        if ( !function_exists( 'ImageCreateFromGIF' ) )
            return false;
        $this->ImageObject = ImageCreateFromGIF( $storedPath . '/' . $storedFile );
        if ( $this->ImageObject )
        {
            $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
            return true;
        }
        return false;
    }
910840
protected function createFile($arrFile) {
        $file = new File();
        $file->setFilePath($arrFile['name']);
        foreach ($arrFile['templates'] as $template) {
            if (substr($template, 0, 1) != "/") {
                $template = codemonkey_pathTemplateDir.$template;
            }
            $file->addTemplate($template);
        }
        if (isset($arrFile['attributes'])) {
            $file->addAttributes($arrFile['attributes']);
        }
        
        if (isset($this->config['attributes'])) {
            $file = $this->addPostAttributes($file);
        }
        
        $file->generate();
    }
1318054
protected function loadIniFile( $fileName )
	{
		if( self::$iniQuickLoad )
		{
			$array	= parse_ini_file( $fileName, TRUE );
			foreach( $array as $sectionName => $sectionData )
				foreach( $sectionData as $key => $value )
					$this->pairs[$sectionName.".".$key]	= $value;
		}
		else
		{
			$pattern	= '@^(string|integer|int|double|boolean|bool).*$@';
			$reader		= new FS_File_INI_Reader( $fileName, TRUE );
			$comments	= $reader->getComments();
			foreach( $reader->getProperties() as $sectionName => $sectionData )
			{
				foreach( $sectionData as $key => $value )
				{
					if( isset( $comments[$sectionName][$key] ) )
					{
						$matches	= array();
						if( preg_match_all( $pattern, $comments[$sectionName][$key], $matches ) )
						{
							$type		= $matches[1][0];
							settype( $value, $type );
						}
					}
					$this->pairs[$sectionName.".".$key]	= $value;
				}
			}
		}
	}
942991
private function initialize()
    {
        foreach ($this->globs as $glob) {
            $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues());

            if (false !== $paths = glob($glob)) {
                foreach ($paths as $path) {
                    if (is_file($path)) {
                        $asset = new FileAsset($path, array(), $this->getSourceRoot(), null, $this->getVars());
                        $asset->setValues($this->getValues());
                        $this->add($asset);
                    }
                }
            }
        }

        $this->initialized = true;
    }
360075
public function writeIniFile(array $parameters, $iniFile)
    {
        $content = '';

        foreach ($parameters as $key => $value) {
            $content .= "{$key} = {$value}\n";
        }

        if (!file_put_contents($iniFile, $content)) {
            throw new \Exception("The claroline cache couldn't be created");
        }
    }
1288136
public static function fromFile($configFile)
    {
        if (false === FileIO::exists($configFile)) {
            throw new ConfigException(sprintf('unable to read "%s"', $configFile));
        }

        return new self(require $configFile);
    }
139130
function readMIMETypeQualitySettingFromINI( $iniFile = false )
    {
        if ( !$iniFile )
            $iniFile = 'image.ini';
        $ini = eZINI::instance( $iniFile );
        if ( !$ini )
            return false;
        if ( !$ini->hasVariable( 'MIMETypeSettings', 'Quality' ) )
            return false;
        $values = $ini->variable( 'MIMETypeSettings', 'Quality' );
        foreach ( $values as $value )
        {
            $elements = explode( ';', $value );
            $mimeType = $elements[0];
            $qualityValue = $elements[1];
            $this->appendQualityValue( $mimeType, $qualityValue );
        }
    }
977786
private function parseParametersFile($pathParametersFile)
    {
        $this->parameters = parse_ini_file($pathParametersFile, true);

        if (isset($this->parameters['environment'])) {
            $this->setEnvironment($this->parameters['environment']);
        }

        if (isset($this->parameters['login'])) {
            $this->setLogin($this->parameters['login']);
        }

        if (isset($this->parameters['password'])) {
            $password = $this->parameters['password'];
            if (empty($this->parameters['isEncryptedPassword'])
            || $this->parameters['isEncryptedPassword'] === false
            || $this->parameters['isEncryptedPassword'] === 'false') {
                $password = $this->encryptPassword($password);
            }

            $this->setPassword($password);
        }

        if (isset($this->parameters['api_key'])) {
            $this->setApiKey($this->parameters['api_key']);
        }

        if (isset($this->parameters['ssl_enabled'])) {
            $this->setEnabledSSL($this->parameters['ssl_enabled']);

            $this->setCertClientLocation($this->parameters['cert_client_location']);
            $this->setCaChainClientLocation($this->parameters['ca_chain_client_location']);
            $this->setPrivateKeyClientLocation($this->parameters['private_key_client_location']);
            $this->setPrivateKeyClientPassword($this->parameters['private_key_client_password']);
        }

        return $this;
    }
863507
protected void loadFSImage(ImageInputStream iis, File imageFile) throws IOException {
    MD5Hash expectedMD5 = MD5FileUtils.readStoredMd5ForFile(imageFile);
    if (expectedMD5 == null) {
      throw new IOException("No MD5 file found corresponding to image file "
          + imageFile);
    }
    iis.setImageDigest(expectedMD5);
    loadFSImage(iis);
  }
193533
public function modify(SplFileInfo $generatedFile, SplFileInfo $templateFile, array $modifiers, Inflector $inflector)
    {
        foreach ($modifiers as $modifierAlias => $modifierData) {
            if ($modifier = $this->contentModifiers->get($modifierAlias)) {
                $this->filesystem->dumpFile(
                    $generatedFile->getRealPath(),
                    $modifier->modify(
                        $generatedFile,
                        is_array($modifierData) ? $modifierData : array(),
                        $inflector,
                        $templateFile
                    )
                );
            }
        }
    }
341758
function addImageAliases( $imageAliasList )
    {
        $domTree = $this->domTree();
        foreach ( $imageAliasList as $imageAliasName => $imageAlias )
        {
            if ( $imageAlias['is_new'] )
            {
                $this->addImageAliasToXML( $domTree, $imageAlias );
                $this->setAliasAttribute( $imageAliasName, 'is_new', false );
            }
        }
        $attr = false;
        $this->storeDOMTree( $domTree, true, $attr );
    }
273931
public static function setConfig($sFile)
	{
		self::$_aTranslator = json_decode(file_get_contents($sFile));
		self::$_bConfigurated = true;
	}
583154
private static function fixImageOrientation(File $imageFile, ImageInterface $image)
    {
        $format = $image->getFormat();

        // exif data is available only on jpeg and tiff
        // tiff is ignored, because smartphones don't produce tiff images
        if ($format == 'jpg' || $format == 'jpeg') {
            $exifData = exif_read_data($imageFile->getAbsolutePath(), 'IFDO');
            if (isset($exifData['Orientation'])) {
                switch ($exifData['Orientation']) {
                    case 3:
                        $rotation = 180;
                        break;
                    case 6:
                        $rotation = 90;
                        break;
                    case 8:
                        $rotation = -90;
                        break;
                    default:
                        $rotation = 0;
                        break;
                }

                if($rotation!=0){
                    $image->rotate($rotation);
                }
            }
        }
    }