+# Argument: path to image file
+#
+# Return: string in the format WIDTHxHEIGHT, or boolean false
+#
+# Example: image_dimensions('uploads/foo.png'); ==> "124x58"
+function image_dimensions($image) {
+ $identify = path_to('identify');
+ $command = "$identify -format '%wx%h' " . escapeshellarg($image);
+ $dimensions = substr(`$command`, 0, -1); # substr() to remove newline
+ if($dimensions == '') {
+ return false;
+ } else {
+ return $dimensions;
+ }
+}
+