#!/usr/bin/env perl

use warnings;
use strict;

my %figures =
    (title => ['0','2400x1600+100+100'],
     fig1a_1 => ['1','750x1200+60+750'],
     fig1a_2 => ['1','750x1200+60+1950'],
     fig1b => ['1','1000x500+810+1200'],
     fig1c => ['1','1000x500+810+1700'],
     fig1d => ['1','1000x500+810+2200'],
     fig2a => ['2','1000x750+200+200'],
     fig2b => ['2','1000x750+1200+200'],
     fig2c => ['2','1000x750+200+950'],
     fig2d => ['2','1000x750+1200+950'],
     fig2e => ['2','1000x650+200+1650'],
     fig2f => ['2','1000x650+1200+1650'],
     fig3  => ['3','1200x1050+100+200'],
     fig_ed1  => ['6','2400x1200+100+100'],
     fig_ed2  => ['7','2400x2400+100+100'],
     fig_ed3  => ['8','2400x2400+100+100'],
     fig_ed4  => ['9','2400x1700+100+100'],
     fig_ed5  => ['10','2400x2400+100+100'],
     fig_ed5  => ['11','2400x2400+100+100'],
    );

for my $figure (keys %figures) {
    print($figure."\n");
    system('convert','-density','300',
           'paper.pdf['.$figures{$figure}[0].']',
           '-crop',$figures{$figure}[1],
           $figure.'.png'
          )
}
