# Cover Dimensions - another approach

**URL:** https://community.mp3tag.de/t/cover-dimensions-another-approach/6421
**Category:** General Discussion
**Created:** [March 10, 2008, 8:13am UTC](https://community.mp3tag.de/t/cover-dimensions-another-approach/6421 "2008-03-10T08:13:12Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)
#### Post date: [March 10, 2008, 8:13am UTC](https://community.mp3tag.de/t/cover-dimensions-another-approach/6421/1 "2008-03-10T08:13:12Z")

</div>

**Cover Dimensions - another approach**

The following method creates some tag fields to hold cover image related data from up to ten stored covers.

This method relies on a helper tool called **identify.exe** , taken from the powerful graphical tools suite made by ImageMagick, which can extract technical informations from a picture.  
(ImageMagick ftp://ftp.imagemagick.org/pub/ImageMagick/binaries/

**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.

Keep in mind that the working folder must be named unique within the later used batch command file resp. export script too.

**3.**  
Run actiongroup 'Get Cover Info Step 2 Create Filelist' against the selection.

This actiongroup creates a textfile in the working folder using the Mp3tag export script 'Export Filelist for ImageMagick identify.mte'.

Begin Actiongroup **Get Cover Info Step 2 Create Filelist**

Action #1  
_Actiontype 15:_ **Export**  
_Select script filename:_ **Export÷Filelist÷for÷ImageMagick÷identify**  
_Export filename:_ **O:\TEST\COVERS\identify.in.txt**

[X] append data[\_] one file per folder

Note: Replace one special character ÷ with one space character.  
End Actiongroup **Get Cover Info Step 2 Create Filelist** (1 Action)

**4.**  
Run actiongroup 'Get Cover Info Step 3 Create Batch' against the selection.

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

Do not forget to adapt the working folder setup within the action script to your needs.  
Look into the Mp3tag export file 'Export CMD for ImageMagick Identify.cmd' and change the working folder and environment variable APP as needed.

Make sure that the helper application 'identify.exe' from ImageMagick is installed and accessible by the batch command file.

Check working folder and adapt top script line '$filename(O:\TEST\COVERS\Mp3tag.iview.info.cmd,ansi)' as needed.

Begin Actiongroup **Get Cover Info Step 3 Create Batch**

Action #1  
_Actiontype 15:_ **Export**  
_Select script filename:_ **Export÷CMD÷for÷ImageMagick÷Identify**  
_Export filename:_ **O:\TEST\COVERS\Mp3tag.magick.identify.cmd**

[\_] append data[\_] one file per folder

Note: Replace one special character ÷ with one space character.  
End Actiongroup **Get Cover Info Step 3 Create Batch** (1 Action)

**5.**  
'Get Cover Info Step 4 Run Batch external' - run the external batch command file in the working folder.

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 'Step 1 Export Covers'.

There is a batch command file named 'Mp3tag.magick.identify.cmd'.

Run the batch command file 'Mp3tag.magick.identify.cmd'.

The batch command file creates a bunch of txt files in the working folder and deletes the previously created jpg files.

**6.**  
Switch back to Mp3tag.

Run the actiongroup 'Get Cover Info Step 5 Set Tags from ImageMagick identify' against the selection.

Begin Actiongroup **Get Cover Info Step 5 Set Tags from ImageMagick identify**

Action #1  
_Actiontype 14:_ **Import text file**  
_Field:_ **COVER\_INFO**  
_Filename:_ **%COVER\_PATH%.out.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 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%COVER1\_TYPE%`%COVER1_SIZE%`%COVER1\_DIM\_W\_H%`%COVER1_RES_W_H%`%COVER1\_QUALITY%|%dummy%**

Action #4  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%COVER2\_TYPE%`%COVER2_SIZE%`%COVER2\_DIM\_W\_H%`%COVER2_RES_W_H%`%COVER2\_QUALITY%|%dummy%**

Action #5  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%COVER3\_TYPE%`%COVER3_SIZE%`%COVER3\_DIM\_W\_H%`%COVER3_RES_W_H%`%COVER3\_QUALITY%|%dummy%**

Action #6  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%COVER4\_TYPE%`%COVER4_SIZE%`%COVER4\_DIM\_W\_H%`%COVER4_RES_W_H%`%COVER4\_QUALITY%|%dummy%**

Action #7  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%COVER5\_TYPE%`%COVER5_SIZE%`%COVER5\_DIM\_W\_H%`%COVER5_RES_W_H%`%COVER5\_QUALITY%|%dummy%**

Action #8  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%COVER6\_TYPE%`%COVER6_SIZE%`%COVER6\_DIM\_W\_H%`%COVER6_RES_W_H%`%COVER6\_QUALITY%|%dummy%**

Action #9  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%COVER7\_TYPE%`%COVER7_SIZE%`%COVER7\_DIM\_W\_H%`%COVER7_RES_W_H%`%COVER7\_QUALITY%|%dummy%**

Action #10  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%COVER8\_TYPE%`%COVER8_SIZE%`%COVER8\_DIM\_W\_H%`%COVER8_RES_W_H%`%COVER8\_QUALITY%|%dummy%**

Action #11  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%COVER9\_TYPE%`%COVER9_SIZE%`%COVER9\_DIM\_W\_H%`%COVER9_RES_W_H%`%COVER9\_QUALITY%|%dummy%**

Action #12  
_Actiontype 7:_ **Import tag fields (guess values)**  
_Source format:_ **%cover\_info%**  
_Guessing pattern:_ **%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%dummy%|%COVER10\_TYPE%`%COVER10_SIZE%`%COVER10\_DIM\_W\_H%`%COVER10_RES_W_H%`%COVER10\_QUALITY%|%dummy%**

End Actiongroup **Get Cover Info Step 5 Set Tags from ImageMagick identify** (12 Actions)

**6.**  
Cleanup Tags.

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

Begin Actiongroup **Get Cover Info Step 6 Remove Temp Tags**

Action #1  
_Actiontype 9:_ **Remove fields**  
_Fields to remove (semicolon separated):_ **COVER\_PATH;COVER\_INFO**

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

**7.**  
Cleanup working folder.

Remove all files from the working folder just by running the same batch command file 'Mp3tag.magick.identify.cmd' again.

**8.**  
Add new columns to the Mp3tag grid view.

[#..]  
width=100  
numeric=0  
name=Cover1 Dim  
value=[%COVER1\_DIM\_W\_H%]  
sort=$mul($replace(%COVER1\_DIM\_W\_H%,'x',','))  
field=  
enabled=1

[#..]  
width=100  
numeric=0  
name=Cover2 Dim  
value=[%COVER2\_DIM\_W\_H%]  
sort=$mul($replace(%COVER2\_DIM\_W\_H%,'x',','))  
field=  
enabled=1

[#..]  
width=71  
numeric=1  
name=Covers Size  
value=[$add($add($add($add($add($add($add($add($add(%COVER1\_SIZE%,%COVER2\_SIZE%),%COVER3\_SIZE%),%COVER4\_SIZE%),%COVER5\_SIZE%),%COVER6\_SIZE%),%COVER7\_SIZE%),%COVER8\_SIZE%),%COVER9\_SIZE%),%COVER10\_SIZE%)]  
sort=  
field=  
enabled=1

... and so on.

**9.**  
Ready.

Regarding on the number of stored cover pictures and limitation by this method one mp3 file gets a set of five ready made tag fields for each cover picture.

```
COVERn_TYPE ..: Image file type as string, e. g. 'JPEG'.
COVERn_SIZE ..: Size in Bytes.
COVERn_DIM_W_H: Dimensions width and height pair in pixel, e. g. '179x200'.
COVERn_RES_W_H: Resolution width and height pair in pixel, e. g. '72x72'.
COVERn_QUALITY: Quality of the compressed image in percent, e. g. '85'.

```

Mp3tag users who do not need those detailed data may use the %COVER\_INFO% tag field alone which contains all the data within one string list.  
To get the %COVER\_INFO% tag field stand alone all 'Import tag fields (guess values)' actions within actiongroup 5 and the string COVER\_INFO within actiongroup 6 have to be deleted.

Once you have understood how the workflow runs you may set up two meta actiongroups by the Mp3tag Utils Dialog, e. g.:  
GetCover Info Step 1-2-3  
GetCover Info Step 4-5-6  
... to achieve nearly a single click feeling (hmm ... not really ... overall maybe just 7 clicks?).

Be aware that Mp3tag is somewhat quirky when exporting cover pictures in the case of duplicate pictures stored in one mp file!

Note to the Mp3tag developer:  
I would like to have even duplicate pictures to be allowed _and_ to be imported _and_ to be exported each as a single file (just because of logical handling and systematic usage)!  
And a a smart wizard background image type repair support too (e. g. auto repair of APIC frame when PNG image is erroneously stored as JPEG type)!

mta files:  
Get\_Cover\_Info\_Step\_1\_Export\_Covers.mta ( 221bytes ) Number of downloads: 192  
Get\_Cover\_Info\_Step\_2\_Create\_Filelist.mta ( 108bytes ) Number of downloads: 310  
Get\_Cover\_Info\_Step\_3\_Create\_Batch.mta ( 114bytes ) Number of downloads: 189  
Get\_Cover\_Info\_Step\_4\_Run\_Batch\_external.mta ( 3bytes ) Number of downloads: 160  
Get\_Cover\_Info\_Step\_5\_Set\_Tags\_from\_ImageMagick\_identify.mta ( 1.62K ) Number of downloads: 197  
Get\_Cover\_Info\_Step\_6\_Remove\_Temp\_Tags.mta ( 41bytes ) Number of downloads: 152

mte file:  
Export\_Filelist\_for\_ImageMagick\_identify.mte ( 109bytes ) Number of downloads: 173  
Export\_CMD\_for\_ImageMagick\_identify.mte ( 3.55K ) Number of downloads: 190

Good luck, folks!  
DD.20080310.1015.CET

Edit: some typos corrected.  
DD.20080310.1944.CET

Removed old scripts.  
DD.20131114.0033.CET

---

_[View the full topic](https://community.mp3tag.de/t/cover-dimensions-another-approach/6421)._
