Is there a way to programmatically extract cover art?

Or you could simply use the MP3::Tag package. This is based on the answer found here

  • Have Perl installed, and enabled for DOpus scripting.
  • Add the MP3::Tag package using PPM.
  • Save this script in the addins folder and enable it
  • create a button with the command
ExtractTagImage

and it'll extract images from all selected mp3's.
As it is, it will create 0 byte files for mp3's without an image.

No guarantees, but it does so here anyway.

use v5.14;
use warnings;
use strict;
use Win32::OLE;
use Win32::OLE qw(in valof with OVERLOAD);
use MP3::Tag;

sub OnInit{
  my $initData=shift;
  my $cmd;
  $initData->{name} = "Extract Tag images";
  $initData->{desc} = "Extract images from tags in selected files";
  $initData->{copyright} = "myarmor";
  $initData->{version}="0.1";
  $initData->{default_enable}=1;

  $cmd = $initData->AddCommand();
  $cmd->{desc} = $initData->{desc};
  $cmd->{hide} = 0;
  $cmd->{icon} = "info";
  $cmd->{label} = "ExtractTagImage";
  $cmd->{method} = "OnExtractTagImage";
  $cmd->{name} = "ExtractTagImage";
  $cmd->{template} = "";
  return 0;
}

sub ExtractImage{
  my ($infile,$outfile)=@_;
  my $id3v2;
  $::DOpus->Output("Extract image from ".$infile);
  my $mp3 = MP3::Tag->new($infile) or die "died in ExtractImage";
  # Get the tags from the MP3
  $mp3->get_tags;
  $id3v2 = $mp3->{ID3v2};
  # Get the APIC frame from the Tag (The Image) which
  # returns a hash ref
  my $Pic = $id3v2->get_frame("APIC"); # returns
  open (SAVE, ">".$outfile);
  binmode SAVE;
  print SAVE $Pic->{_Data};
  close SAVE;
}

# Implement the TestIt command
sub OnExtractTagImage{
  my $scriptCommandData=shift;
  my $filename;
  my $mi;
  my $Data;
  #disable deselect
  $scriptCommandData->func->command->{deselect}=0;

  foreach my $item (in ($scriptCommandData->func->sourcetab->selected)){
    $::DOpus->Output($item->realpath);
    $filename=$item->realpath;
    ExtractImage($filename,$item->realpath."_output.jpg");
  }
}


# Called to display an About dialog for this script
sub OnAboutScript{
  my $aboutData=shift;
  my $dlg = $::DOpus->Dlg();
  $dlg->{window} = $aboutData->window;
  $dlg->{message} = "ExtractTagImage";
  $dlg->{title} = "About ExtractTagImage";
  $dlg->{buttons} = "OK";
  $dlg->{icon} = "info";
  $dlg->Show();
}

1;

ExtractImages.zip (955 Bytes)