Native libsass plugin adding functions to query image dimensions.
Introduction
This plugin only supports PNG, JPG and GIF image formats. These are the common
image formats used on the web (beside SVG maybe). Those three image formats are
well defined and querying the dimensions is rather simple. Therefore we don't
need any 3rd party image libraries to get the job done.
Building
You need to have libsass already compiled or installed as a
shared library (inclusive header files). It is then compiled via cmake. See
this example to compile it on windows via MinGW Compiler Suite:
You may define LIBSASS_INCLUDE_DIR and LIBSASS_LIBRARY_DIR separately!
API
The following functions are available when you import the img-size plugin.
image-size($url) - Returns image dimensions as a list with spaces
image-width($url) - Returns image width as number with px as unit
image-height($url) - Returns image height as number with px as unit
The url is resolved via sass_compiler_find_file, which will in turn look for
the given file in all include directories. The first file encountered will be
used. If no file can be found, a error is raised.