add image height and width to file name

Post any Bulk Rename Utility support requirements here. Open to all registered users.

add image height and width to file name

Postby jay gray » Fri Dec 08, 2017 10:02 am

On Windows 10 and for a PNG or JPG/JPEG, is it possible to extract the height and width dimensions from file properties and append those properties to the file name? For example:

for file.png with Details (from Win10 Properties)
Dimensions 27 x 18
Width 27 pixels
Height 18 pixels

replace file.png with:
file_w27_h18.png
or
file 27 x 18.png (taking the values from the Dimensions field - I can later replaces spaces with a character separator like underscore)

/jay gray
jay gray
 
Posts: 3
Joined: Fri Dec 08, 2017 9:09 am

Re: add image height and width

Postby JohnDepot » Fri Aug 14, 2020 5:37 pm

Same problem, looking to add a prefix of "000x000' with Height and Width of a folder of BMP files.
JohnDepot
 
Posts: 3
Joined: Fri Aug 14, 2020 5:35 pm

Re: add image height and width

Postby JohnDepot » Fri Aug 14, 2020 8:03 pm

Found a solution;

Using Javascript Renaming (12) to append the width and height of the image onto the end of the file name.

Ex. Image.bmp -> Image_100x100.bmp

var width = filePropertyNum('Width');
var height = filePropertyNum('Height');
newName = name + '_[' + width + 'x' + height +']'

I will keep playing with it because i want to make sure there is a 3 digit buffer, so that 80x93 will be 080x093, and post an update when I get it!
JohnDepot
 
Posts: 3
Joined: Fri Aug 14, 2020 5:35 pm

Re: add image height and width

Postby JohnDepot » Fri Aug 14, 2020 8:09 pm

var w = filePropertyNum('Width');
var h = filePropertyNum('Height');

function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}

var width = pad(w,3);
var height = pad(h,3);

newName = name + '_-_[' + width + 'x' + height +']'
JohnDepot
 
Posts: 3
Joined: Fri Aug 14, 2020 5:35 pm


Return to BRU Support