-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better performance for reading dimensions of SVG images #23
Conversation
A quick performance test looks promising:
In comparison reading the size of a jpg/png/gif reaches about 23,500 images/sec. |
I think it is: http://php.net/manual/de/ref.zlib.php#37482 |
If we want to be sure we could add an |
Maybe in the Contao check or Contao manager but rather not in the core. On a page with 100 images, the check would be executed 100 times otherwise. |
@@ -176,15 +176,27 @@ public function setImportantPart(ImportantPartInterface $importantPart = null) | |||
*/ | |||
private function getSvgSize() | |||
{ | |||
static $zlibSupport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a static class property such as self::$zlibSupport
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think so, because it is only used in this method and nowhere else.
The exception would be if our styleguide doesn’t allow static function variables at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, our style guide does not forbid to use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I keep it as is then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if you prefer. 😄
With this PR
Image::getDimensions()
reads SVG files only partially to save IO, parsing time and memory. And it doesn’t callgetimagesize()
on SVG images anymore.Todo:
compress.zlib://
is supported on all platforms