Libsass Image Size Plugin
Native libsass plugin adding functions to query image dimensions.
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.
git clone https://github.com/sass/libsass.git
mingw32-make -C libsass BUILD=shared CC=gcc -j5
git clone https://github.com/mgreter/libsass-img-size.git
cd libsass-img-size && mkdir build && cd build
cmake -G "MinGW Makefiles" .. -DLIBSASS_DIR="..\..\libsass"
mingw32-make CC=gcc -j5 && dir img-size.dll
You may define
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
image-height($url)- Returns image height as number with
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.
© 2017 Marcel Greter