\href{https://www.npmjs.com/package/image-size}{\texttt{ }} \href{https://travis-ci.org/image-size/image-size}{\texttt{ }} \href{http://npm-stat.com/charts.html?package=image-size&author=&from=&to=}{\texttt{ }} \href{https://coveralls.io/github/image-size/image-size?branch=master}{\texttt{ }} \href{https://david-dm.org/image-size/image-size\#info=devDependencies}{\texttt{ }}

A \href{https://nodejs.org/en/}{\texttt{ Node}} module to get dimensions of any image file\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12647}{}\doxysection{Supported formats}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12647}

\begin{DoxyItemize}
\item BMP
\item GIF
\item JPEG
\item PNG
\item PSD
\item TIFF
\item WebP
\item SVG
\item DDS
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12648}{}\doxysubsection{Upcoming}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12648}

\begin{DoxyItemize}
\item SWF
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12649}{}\doxysection{Programmatic Usage}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12649}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install image-\/size -\/-\/save }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12650}{}\doxysubsection{Synchronous}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12650}

\begin{DoxyCode}{0}
\DoxyCodeLine{var sizeOf = require('image-\/size');}
\DoxyCodeLine{var dimensions = sizeOf('images/funny-\/cats.png');}
\DoxyCodeLine{console.log(dimensions.width, dimensions.height); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12651}{}\doxysubsection{Asynchronous}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12651}

\begin{DoxyCode}{0}
\DoxyCodeLine{var sizeOf = require('image-\/size');}
\DoxyCodeLine{sizeOf('images/funny-\/cats.png', function (err, dimensions) \{}
\DoxyCodeLine{  console.log(dimensions.width, dimensions.height);}
\DoxyCodeLine{\}); }

\end{DoxyCode}
 NOTE\+: The asynchronous version doesn\textquotesingle{}t work if the input is a Buffer. Use synchronous version instead.\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12652}{}\doxysubsection{Using a URL}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12652}

\begin{DoxyCode}{0}
\DoxyCodeLine{var url = require('url');}
\DoxyCodeLine{var http = require('http');}
\DoxyCodeLine{}
\DoxyCodeLine{var sizeOf = require('image-\/size');}
\DoxyCodeLine{}
\DoxyCodeLine{var imgUrl = 'http://my-\/amazing-\/website.com/image.jpeg';}
\DoxyCodeLine{var options = url.parse(imgUrl);}
\DoxyCodeLine{}
\DoxyCodeLine{http.get(options, function (response) \{}
\DoxyCodeLine{  var chunks = [];}
\DoxyCodeLine{  response.on('data', function (chunk) \{}
\DoxyCodeLine{    chunks.push(chunk);}
\DoxyCodeLine{  \}).on('end', function() \{}
\DoxyCodeLine{    var buffer = Buffer.concat(chunks);}
\DoxyCodeLine{    console.log(sizeOf(buffer));}
\DoxyCodeLine{  \});}
\DoxyCodeLine{\}); }

\end{DoxyCode}


You can optionally check the buffer lengths \& stop downloading the image after a few kilobytes. {\bfseries{You don\textquotesingle{}t need to download the entire image}}\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12653}{}\doxysection{Command-\/\+Line Usage (\+CLI)}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12653}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install image-\/size -\/-\/global}
\DoxyCodeLine{image-\/size image1 [image2] [image3] ... }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12654}{}\doxysection{Credits}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12654}
not a direct port, but an attempt to have something like \href{https://github.com/dabble/imagesize/blob/master/lib/image_size.rb}{\texttt{ dabble\textquotesingle{}s imagesize}} as a node module.\hypertarget{md_sfcode_node_modules_image_size_Readme_autotoc_md12655}{}\doxysection{@ref Contributors.\+md \char`\"{}\+Contributors\char`\"{}}\label{md_sfcode_node_modules_image_size_Readme_autotoc_md12655}
