Cover Dimensions


#1

Cover Dimensions

The following method creates two tag fields to hold the wide and height values from the first stored cover.

You need a helper tool called IrfanView which extracts the information from the picture.

1.
In Mp3tag grid view mark the tracks to be changed.

2.
Run the actiongroup Get Cover Info Step 1 Export Covers against the selection.

Begin Actiongroup Get Cover Info Step 1 Export Covers

Action #1
Actiontype 5: Format tag field
Field: COVER_PATH
Formatstring: $replace(%_folderpath%%_filename%,,`,:,)

Action #2
Actiontype 4: Replace with regular expression
Field: COVER_PATH
Regular expression: [^\x2F-\x7F]
Replace matches with:

[_] case sensitive comparison

Action #3
Actiontype 5: Format tag field
Field: COVER_PATH
Formatstring: O:\TEST\COVERS\%COVER_PATH%

Action #4
Actiontype 13: Export cover image to file
Formatstring for image filename: %COVER_PATH%

End Actiongroup Get Cover Info Step 1 Export Covers (4 Actions)

You may change the path to the working folder to fit your needs.
Change in Action #3 the partial string 'O:\TEST\COVERS' to the location of your choice.

3.
Run actiongroup Get Cover Info Step 2 Create Batch against the selection.

This actiongroup creates a batch command file in the working folder.

4.
Get Cover Info Step 3 Run Batch

Use some File Explorer and look into the working folder, e. g. 'O:\TEST\COVERS'.

There is a bunch of jpg files as the result from the previous actiongroup run.

There is a txt file named 'Mp3tag.iview.info.cmd.txt'.

To set the batch command file ready to work just delete the extension '.txt' to name it 'Mp3tag.iview.info.cmd'.

Make sure that the helper application 'IrfanView' (i_view32.exe) is installed and accessible by the batch command file.
Look into the Mp3tag export file 'Export BAT for IrfanView Info.mte' and change the environment variable APP as needed.
Change the working folder to the same folder as before, see line
'$filename(O:\TEST\COVERS\Mp3tag.iview.info.cmd.txt,ansi)'.

Run the batch command file 'Mp3tag.iview.info.cmd'.

The batch command file creates a bunch of txt files in the working folder.

5.
Switch back to Mp3tag.

Run the actiongroup Get Cover Info Step 4 Set Tags against the selection.

Begin Actiongroup Get Cover Info Step 4 Set Tags

Action #1
Actiontype 14: Import text file
Field: COVER_INFO
Filename: %COVER_PATH%.txt

Action #2
Actiontype 4: Replace with regular expression
Field: COVER_INFO
Regular expression: [\r\n]
Replace matches with:

[_] case sensitive comparison

Action #3
Actiontype 5: Format tag field
Field: COVER_WIDTH
Formatstring: %COVER_INFO%

Action #4
Actiontype 5: Format tag field
Field: COVER_HEIGHT
Formatstring: %COVER_INFO%

Action #5
Actiontype 4: Replace with regular expression
Field: COVER_WIDTH
Regular expression: ^(.Image√∑dimensions√∑=√∑)(\d+)(√∑x√∑)(\d+)(√∑√∑Pixels.)$
Replace matches with: $2

[X] case sensitive comparison

Action #6
Actiontype 4: Replace with regular expression
Field: COVER_HEIGHT
Regular expression: ^(.Image√∑dimensions√∑=√∑)(\d+)(√∑x√∑)(\d+)(√∑√∑Pixels.)$
Replace matches with: $4

[X] case sensitive comparison

Note: Replace one special character √∑ with one space character.
End Actiongroup Get Cover Info Step 4 Set Tags (6 Actions)

6.
Cleanup.

Run the actiongroup Get Cover Info Step 5 Remove Temp Tags against the selection.

Begin Actiongroup Get Cover Info Step 5 Remove Temp Tags

Action #1
Actiontype 9: Remove fields
Fields to remove (semicolon separated): COVER_PATH;COVER_INFO

End Actiongroup Get Cover Info Step 5 Remove Temp Tags (1 Action)

Remove all files from the working folder.

7.
Add new columns to the Mp3tag grid view.

[#..]
width=72
numeric=1
name=Cover Width
value=%COVER_WIDTH%
sort=
field=
enabled=1

[#..]
width=72
numeric=1
name=Cover Height
value=%COVER_HEIGHT%
sort=
field=
enabled=1

or combine the two values in one column

[#..]
width=100
numeric=0
name=Cover Dim
value=[%COVER_WIDTH% x %COVER_HEIGHT%]
sort=$mul(%COVER_WIDTH%,%COVER_HEIGHT%)
field=
enabled=1

8.
Ready.

mta files:
Get_Cover_Info_Step_1_Export_Covers.mta (221 Bytes)
Get_Cover_Info_Step_2_Create_Batch.mta (107 Bytes)
Get_Cover_Info_Step_3_Run_Batch_external.mta (3 Bytes)
Get_Cover_Info_Step_4_Set_Tags.mta (393 Bytes)
Get_Cover_Info_Step_5_Remove_Temp_Tags.mta (41 Bytes)

mte file:
Export_BAT_for_IrfanView_Info.mte (1.69 KB)

Good luck, folks!

(How easy would it be to have cover dimension support by native Mp3tag!)
DD.20080306.2130.CET

Get_Cover_Info_Step_2_Create_Batch.mta (107 Bytes)

Get_Cover_Info_Step_3_Run_Batch_external.mta (3 Bytes)

Get_Cover_Info_Step_4_Set_Tags.mta (393 Bytes)

Get_Cover_Info_Step_5_Remove_Temp_Tags.mta (41 Bytes)

Export_BAT_for_IrfanView_Info.mte (1.69 KB)

Get_Cover_Info_Step_1_Export_Covers.mta (221 Bytes)


AlbumCover
#2

Great work!

and 100% ACK!! :w00t:


#3

I think it would be easy for Florian to support right now a tag field containing a list of width-height-dimension pairs of all stored covers, e. g. '200 x 200\\179 x 150\\1141 x 1141' (using the Mp3tag multiple field delimiter) or '200x200|179x150|1141x1141' (using some user defined delimiter).

If there would be such a function ...

$ItemExtract
Returns the selected item from a list.

Syntax:
$ItemExtract (index, list, delimiter)

Parameters:
(i) index: the position in list of the item to be selected.
(s) list: a string containing a list of items.
(s) delimiter: a character to act as a delimiter between items in the list.

Returns:
(s) the selected item.

Note: Using -1 as the index will return the last item in the list. 

... someone could easily extract one dimension pair out of the list regarding the n-th stored cover.

Example:
Tagfield COVER_DIMS holds '200x200|179x150|1141x1141'.

$ItemExtract(2,%COVER_DIMS%,'|') will give '179x150' (pair of dimensions of the second cover).

Using the same function again on the extracted pair someone could easily extract both dimension values separately.
$ItemExtract($ItemExtract(2,%COVER_DIMS%,'|'),1,'x') will give '179' (width value of the second cover.
$ItemExtract($ItemExtract(2,%COVER_DIMS%,'|'),2,'x') will give '150' (height value of the second cover.

DD.20080307.0838.CET