Download the PHP package mathiasreker/php-svg-optimizer without Composer
On this page you can find all versions of the php package mathiasreker/php-svg-optimizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mathiasreker/php-svg-optimizer
More information about mathiasreker/php-svg-optimizer
Files in mathiasreker/php-svg-optimizer
Package php-svg-optimizer
Short Description php-svg-optimizer is a PHP library designed to optimize SVG files by applying various transformations and cleanup operations.
License MIT
Homepage https://github.com/mathiasreker/php-svg-optimizer
Informations about the package php-svg-optimizer
PHP SVG Optimizer
php-svg-optimizer
is a PHP library designed to optimize SVG files by applying various transformations and cleanup
operations.
Versions & Dependencies
Version | PHP | Documentation |
---|---|---|
^1.0 | ^8.2 | current |
Requirements
ext-dom
: Required PHP extension for XML handling.
Installation
To install the library, run:
Example
Documentation
The constructor initializes the optimizer with the source SVG file and the output file:
removeTitleAndDesc
Removes <title>
and <desc>
tags from the SVG.
removeComments
Removes all comments from the SVG.
removeUnnecessaryWhitespace
Cleans up unnecessary whitespace in the SVG.
removeDefaultAttributes
Removes default attribute values that match common defaults.
flattenGroups
Flattens nested <g>
elements, moving their child elements up to the parent node.
convertColorsToHex
Converts rgb()
color values to hexadecimal format.
minifySvgCoordinates
Minifies coordinate values by removing unnecessary precision.
minifyTransformations
Minifies transformation attributes by removing redundant values.
optimize
Finalizes the optimization process and generates the optimized SVG file.
Roadmap
For a complete list of proposed features and known issues, see the open issues.
Contributing
Contributions are welcome! If you have suggestions for improvements, please fork the repository and create a pull request. You can also open an issue with the tag "enhancement." Don’t forget to give the project a star if you find it useful!
Docker
To use the project with Docker, you can start the container using:
Then, access the container:
Tools
PHP Coding Standards Fixer:
PHP Coding Standards Checker:
PHP Stan (level 9):
Unit tests:
Magic number detector:
Run all formatting tools:
License
This project is licensed under the MIT License. See the LICENSE file for more information.
All versions of php-svg-optimizer with dependencies
ext-dom Version *
ext-libxml Version *