1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #!/usr/bin/perl
use strict;
use warnings;
use Image::Info qw(image_info dim);
use GD::Image;
my $image1 = 'bad.png';
my $image2 = 'ok.png';
my $image_info1 = image_info($image1);
my $image_info2 = image_info($image2);
print "$image1\n";
print $image_info1->{color_type}, "\n";
print "$image2\n";
print $image_info2->{color_type}, "\n";
# réenregistrer l'image 1 pour modifier le color_type
#####################################################
my $bon = 'bon.png';
my $image_bon = image_info($bon);
print "\n$bon\n";
print $image_bon->{color_type}, "\n";
my $source_file = "mauvais.png";
my $target_file = "essai.png";
my $image = newFromPng GD::Image($source_file, 1) || die "Impossible ouvrir image ! $!";
(my $width, my $height) = $image->getBounds();
print "$width $height\n";
my $imageA = $image->clone;
open(DATEI ,">$target_file") || die "Ouverture impossible : $!";
binmode DATEI;
print DATEI ($imageA->png());
close(DATEI);
my $essai = 'essai.png';
my $image_essai = image_info($essai);
print "\n$essai\n";
print $image_essai->{color_type}, "\n"; |
Partager