<commit_before>#!/usr/bin/perl
$pdf = shift;
$fileprefix = $pdf;
$fileprefix =~ s/.pdf//;

$first = shift;
$last = shift;

system("convert -density 300 $pdf $fileprefix.jpg");

#Parlementaire
#@crop = ('35%,15%,50%', '5%,35%,28%,28%,5%','5%,36%,49%,10%', '5%,32%,27%,28%,5%', '5%,32%,26%,32%,2%', '5%,28%,67%');

#Ministres
@crop = ('30%,21%,49%', '5%,31%,59%,5%','5%,49%,41%,5%', '5%,42%,43%,10%', '5%,45%,45%,5%', '5%,50%,40%,5%');
$last = $last || $#crop;

for($i = $first*1 ; $i <= $last ; $i++) {
    $size = 0; $y = 0;
    @positions = split ',', $crop[$i];
    $tmpdir = '.tmp/';
    mkdir($tmpdir);
    foreach $pc (@positions) {
	$resfile = 'cropped_'.$fileprefix."-".$i."_".$y++.".jpg";
	system("convert ".$fileprefix."-".$i.".jpg -crop 100%x".$pc."+0+".$size." ".$tmpdir.$resfile);
	system("convert ".$tmpdir.$resfile." -fill black -colorize 50% ".$tmpdir."black_".$resfile);
	open(IDENT, "identify ".$tmpdir.$resfile." |");
	$ident = <IDENT>,
	$ident =~ /x([\d+]+) /;
	$size += $1;
    }
    for($y = 0 ; $y <= $#positions ; $y++) {
	$cmd = "convert ";
	for($z = 0 ; $z <= $#positions ; $z++) {
	    $add = 'black_cropped_';
	    $add = 'cropped_' if ($z == $y) ;
	    $cmd .= $tmpdir.$add.$fileprefix.'-'.$i.'_'.$z.'.jpg ';
	}
	$cmd .= ' -append '.$fileprefix.'-mask-'.$i.'_'.$y.'.jpg';
	system($cmd);
    }
}<commit_msg>Image plus proche des besoins en terme d'interface<commit_after>#!/usr/bin/perl
$pdf = shift;
$fileprefix = $pdf;
$fileprefix =~ s/.pdf//;

$first = shift;
$last = shift;

system("convert -density 300 $pdf $fileprefix.jpg");

#Parlementaire
#@crop = ('35%,15%,50%', '5%,35%,28%,28%,5%','5%,36%,49%,10%', '5%,32%,27%,28%,5%', '5%,32%,26%,32%,2%', '5%,28%,67%');

#Ministres
@crop = ('30%,21%,49%', '5%,31%,59%,5%','5%,49%,41%,5%', '5%,42%,43%,10%', '5%,45%,45%,5%', '5%,50%,40%,5%');
$last = $last || $#crop;

for($i = $first*1 ; $i <= $last ; $i++) {
    $size = 0; $y = 0;
    @positions = split ',', $crop[$i];
    $tmpdir = '.tmp/';
    mkdir($tmpdir);
    foreach $pc (@positions) {
	$resfile = 'cropped_'.$fileprefix."-".$i."_".$y++.".jpg";
	system("convert ".$fileprefix."-".$i.".jpg -crop 100%x".$pc."+0+".$size." ".$tmpdir.$resfile);
	open(IDENT, "identify ".$tmpdir.$resfile." |");
	$ident = <IDENT>,
	$ident =~ /x([\d+]+) /;
	$size += $1;
	system("mogrify -resize 1000x1000 ".$tmpdir.$resfile);
	system("convert ".$tmpdir.$resfile." -fill black -colorize 50% ".$tmpdir."black_".$resfile);
	system("convert ".$tmpdir."black_".$resfile." -gravity South -crop 1000x100+0+0 ".$tmpdir."black_bottom_".$resfile);
	system("convert ".$tmpdir."black_".$resfile." -gravity North -crop 1000x100+0+0 ".$tmpdir."black_top_".$resfile);
    }
    for($y = 0 ; $y <= $#positions ; $y++) {
	$cmd = "convert ";
	if ($y) {
	    $cmd .= $tmpdir."black_bottom_cropped_".$fileprefix.'-'.$i.'_'.($y*1-1).'.jpg ';
	}
	$cmd .= $tmpdir."cropped_".$fileprefix.'-'.$i.'_'.$y.'.jpg ';
	if ($y != $#positions) {
	    $cmd .= $tmpdir."black_top_cropped_".$fileprefix.'-'.$i.'_'.($y*1+1).'.jpg ';	    
	}
	$cmd .= ' -append '.$fileprefix.'-mask-'.$i.'_'.$y.'.jpg';
	system($cmd);
    }
}
{'fraction_non_alphanumeric': 0.32526621490803487, 'fraction_numerical': 0.07002258793159083, 'mean_word_length': 3.9363057324840764, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5250429', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1371, 'n_words': 220}