@param string       $originalUrl
@param array|string $filtersOrConfigurationKey
@param array        $extraFilters

@return string
@throws \Sparwelt\ImgixLib\Exception\ResolutionException
342637
public function generateAttributeValue($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
    {
        $filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);

        return $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
    }
49381
public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null)
    {
        $params = [
            'path' => ltrim($path, '/'),
            'filter' => $filter,
        ];

        if ($resolver) {
            $params['resolver'] = $resolver;
        }

        if (empty($runtimeConfig)) {
            $filterUrl = $this->router->generate('liip_imagine_filter', $params, UrlGeneratorInterface::ABSOLUTE_URL);
        } else {
            $params['filters'] = $runtimeConfig;
            $params['hash'] = $this->signer->sign($path, $runtimeConfig);

            $filterUrl = $this->router->generate('liip_imagine_filter_runtime', $params, UrlGeneratorInterface::ABSOLUTE_URL);
        }

        return $filterUrl;
    }
291320
public function getParamsFilters($additionalFields = [])
    {
        if (is_array($additionalFields) && !empty($additionalFields))
        {
            $this->filterParams = array_merge_recursive($this->filterParams, $additionalFields);
        }

        return $this->filterParams;
    }
1334809
protected function getUrlOptionsFromConfig(
        $urlConfig,
        array $defaultOptions
    ) {
        $urlOptions = (
            is_array($urlConfig) &&
            isset($urlConfig[2]) &&
            is_array($urlConfig[2])
        )
            ? $urlConfig[2]
            : [];

        return array_merge(
            $defaultOptions,
            $urlOptions
        );
    }
342139
public function transformHtml($originalHtml, array $attributesFilters = [])
    {
        // regex is used because:
        // 1 - preserves the original html, that would otherwise change when converted to a DOM abstraction
        // 2 - works with invalid surrounding html
        return preg_replace_callback('/(<img[^>]+>)/i', function ($matches) use ($attributesFilters) {
            try {
                return $this->imageTransformer->transformImage($matches[0], $attributesFilters);
            } catch (\Exception $e) {
                if ($e instanceof ResolutionException || $e instanceof TransformationException) {
                    return $matches[0];
                }
                throw $e;
            }
        }, $originalHtml);
    }
482208
@Override
	public String getOriginalUrl() {
		String url = get(CAPTURE_ORIGINAL_URL);
		if (url == null) {
			// convert from ORIG_HOST to ORIG_URL here:
			url = getUrlKey();
			String host = get(CAPTURE_ORIGINAL_HOST);
			if (url != null && host != null) {
				StringBuilder sb = new StringBuilder(url.length());
				sb.append(UrlOperations.DEFAULT_SCHEME);
				sb.append(host);
				sb.append(UrlOperations.getURLPath(url));
				url = sb.toString();
				// cache it for next time...?
				setOriginalUrl(url);
			}
		}
		return url;
	}
124426
public static function formatAndResolvePath($pathOrPaths, ...$additionalPaths)
    {
        $path = rawurldecode(self::mergePaths($pathOrPaths, ...$additionalPaths));
        $path = realpath($path);

        if (!$path) {
            throw new DataHandlingException("Given path does not exist.");
        }

        return self::formatPath($path);
    }
40821
public static Filter<URI> adaptFilterString2URI(final Filter<String> original) {
		return new AbstractFilter<URI>() {
			@Override
			public boolean apply(final URI uri) {
				return original.apply(uri.toString());
			}
			@Override
			public String toString() {
				return original.toString();
			}
			@Override
			public Filter<URI> copy() {
				return adaptFilterString2URI(original.copy());
			}
		};
	}
176123
protected function getFileContent($originalFile, $cacheFile)
    {
        $this->beforeFilter($originalFile, $cacheFile);
        // Run through each filter
        foreach ($this->filters as $filterName => $Filter) {
            $arguments = isset($this->request->params[$filterName]) ?
                $this->request->params[$filterName] : array();
            if (! is_array($arguments)) {
                $arguments = array($filterName => $arguments);
            }
            // Do not minify if .min. is in the filename as it has already been minified
            if(strpos($originalFile, '.min.') !== FALSE) {
                $arguments['minify'] = false;
            }
            $Filter->doFilter($cacheFile, $arguments, $this->options);
        }

        $this->afterFilter($originalFile, $cacheFile);
        $this->lastModifiedDate = time();

        return file_get_contents($cacheFile);
    }
1033250
public function generateUrl($originalUrl, array $filterParams = [])
    {
        if (empty($originalUrl)) {
            throw new ResolutionException('Empty url');
        }

        $cdn = $this->cdnSelector->getCdnForImage($originalUrl);

        $queryParams = $cdn->isGenerateFilterParams() ? array_merge($cdn->getDefaultQueryParams(), $filterParams) : [];

        if (Utils::isMatrix($queryParams)) {
            throw new ConfigurationException(
                sprintf('Monodimensional array expected, matrix given as query parameters: %s', serialize($queryParams))
            );
        }

        $cdnId = spl_object_hash($cdn);
        $shardStrategy = $this->translateShardStrategy($cdn->getShardStrategy());

        if (!isset($this->builders[$cdnId])) {
            try {
                $this->builders[$cdnId] = new UrlBuilder(
                    $cdn->getCdnDomains(),
                    $cdn->isUseSsl(),
                    $cdn->getSignKey(),
                    $shardStrategy,
                    false
                );
            } catch (\InvalidArgumentException $e) {
                throw new ResolutionException($e->getMessage());
            }
        }

        $imagePath = parse_url($originalUrl, PHP_URL_PATH);

        if (false === $imagePath) {
            throw new ResolutionException(sprintf('Malformed image url %s', $originalUrl));
        }

        return $this->builders[$cdnId]->createURL(parse_url($originalUrl, PHP_URL_PATH), $queryParams);
    }
811959
public function generateAttributeValue($sourceImageUrl, $filters = [])
    {
        // ['1x' => ['w' => 123, 'h' => 200], '2x' = > [..]]
        if (Utils::isMatrix($filters)) {
            $srcset = [];
            foreach ($filters as $format => $formatFilters) {
                $srcset[] = sprintf(
                    '%s %s',
                    $this->urlGenerator->generateUrl($sourceImageUrl, $formatFilters),
                    $format
                );
            }

            return implode(', ', $srcset);
        }

    // ['w' => 123, 'h' => 200]
        if (is_array($filters)) {
            return $this->urlGenerator->generateUrl($sourceImageUrl, $filters);
        }

        // '(min-width: 36em) 33.3vw, 100vw' or 'auto' (e.g. 'sizes')
        if (is_scalar($filters)) {
            return $filters;
        }

        throw new ConfigurationException('Filters should be either array or scalar');
    }
26067
protected function beforeFilter($originalFile, $cacheFile)
    {
        if ($this->isLess($originalFile)) {
            $less = new lessc();
            try {
                $compiledLess = $less->cachedCompile($originalFile);
            } catch (\Exception $e) {
                throw new CompilationException('Error in LESS Compiler', 0, $e);
            }
            $compiledLess['compiled'] = $this->fixRelativePaths($compiledLess['compiled'], $originalFile);
            file_put_contents($cacheFile, serialize($compiledLess));
        } elseif ($this->isScss($originalFile)) {
            $scss = new ScssCompiler();
            $scss->addImportPath(pathinfo($originalFile, PATHINFO_DIRNAME));
            try {
                $compiled = $scss->compile(file_get_contents($originalFile));
            } catch (\Exception $e) {
                throw new CompilationException('Error in SCSS Compiler', 0, $e);
            }

            $content = compact('compiled');
            $parsedFiles = $scss->getParsedFiles();
            $parsedFiles[] = $originalFile;
            foreach ($parsedFiles as $file) {
                $content['files'][$file] = filemtime($file);
            }

            $content['compiled'] = $this->fixRelativePaths($content['compiled'], $originalFile);
            file_put_contents($cacheFile, serialize($content));
        } else {
            $content = file_get_contents($originalFile);
            file_put_contents($cacheFile, $this->fixRelativePaths($content, $originalFile));
        }
    }
319399
public static function createFromConfiguration(array $cdnConfiguration, array $filtersConfigurations = [])
    {
        $cdnSelector = new CdnSelector(...CdnConfigurationParser::parseArray($cdnConfiguration));
        $urlGenerator = new ImgixUrlGenerator($cdnSelector);
        $attributeGenerator = new AttributeGenerator($urlGenerator);

        $imageRenderer = new ImageRenderer();
        $imageTransformer = new ImageTransformer($attributeGenerator, $imageRenderer);
        $imageGenerator = new ImageGenerator($attributeGenerator, $imageRenderer);
        $htmlConverter = new HtmlTransformer($imageTransformer);

        return new ImgixService($urlGenerator, $attributeGenerator, $imageGenerator, $htmlConverter, $filtersConfigurations);
    }
531949
protected function beforeFilter($originalFile, $cacheFile)
    {
        if ('coffee' == pathinfo($originalFile, PATHINFO_EXTENSION)) {
            $coffeeScript = CoffeeScript\Compiler::compile(file_get_contents($originalFile), array('header' => false));
            file_put_contents($cacheFile, $coffeeScript);
        }
    }
472513
public static function formatAndResolveDirectory($pathOrPaths, ...$additionalPaths)
    {
        $directory = self::formatAndResolvePath($pathOrPaths, ...$additionalPaths);

        if ($directory) {
            $directory = rtrim($directory, "/") . "/";
        }

        return $directory;
    }
1279486
public function setAdditionalFilters($additionalFilters)
    {
        $path = $this->prefixWithNamespace('additionalFilters');
        $this->argumentsAccessor->set($path, $additionalFilters);
        $this->stateChanged = true;

        return $this;
    }
1001600
public static function excludeQueryParametersFromUrl($originalUrl, $idSite)
    {
        $originalUrl = self::cleanupUrl($originalUrl);

        $parsedUrl = @parse_url($originalUrl);
        $parsedUrl = self::cleanupHostAndHashTag($parsedUrl, $idSite);
        $parametersToExclude = self::getQueryParametersToExclude($idSite);

        if (empty($parsedUrl['query'])) {
            if (empty($parsedUrl['fragment'])) {
                return UrlHelper::getParseUrlReverse($parsedUrl);
            }

            // Exclude from the hash tag as well
            $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['fragment']);
            $parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude);
            $url = UrlHelper::getParseUrlReverse($parsedUrl);

            return $url;
        }

        $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['query']);
        $parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude);
        $url = UrlHelper::getParseUrlReverse($parsedUrl);

        return $url;
    }