Thank You for your continued support and contributions!
#!/usr/bin/perluse strict;use Imager;use MP3::Tag;use Data::Dumper;my $input = "~/Documents/test.mp3";my $mp3 = MP3::Tag->new($input);my @tags = $mp3->get_id3v2_frame_ids();print Dumper(@tags);if ($mp3->have_id3v2_frame_by_descr("APIC")) { print "Picture exists\n"; # Read the image into a variable my $png_img = $mp3->select_id3v2_frame_by_descr("APIC"); # Import the image into Imager for conversion if (open(my $fh_png, "<:raw", \$png_img)){ print "Is PNG\n"; my $converter = Imager->new(); $converter->read(fh=>$fh_png); $converter = $converter->scale(xpixels=>1000, ypixels=>1000, type=>'min'); my $jpg_img; # Write to a stream that can be written into the ID# tag open(my $fh_jpg, ">:raw", \$jpg_img) or die "Cannot open JPG stream"; $converter->write(fh=>$fh_jpg, type=>"jpeg", jpeg_progressive=>0) or die "Cannot write: ", $converter->errstr; close($fh_jpg); # Write to a file open(my $fh, ">:raw", "~/Documents/test.jpg") or die "Cannot open JPG file"; $converter->write(fh=>$fh, type=>"jpeg", jpeg_progressive=>0) or die "Cannot write: ", $converter->errstr; close($fh); # Update the ID3 tag $mp3->select_id3v2_frame_by_descr("APIC", $jpg_img) or die "Cannot update MP3"; $mp3->config(write_v24 => 1) or die "Cannot set config"; $mp3->update_tags() or die "Cannot update tags"; close($fh_png); }}
write_v24If FALSE (default), writing of ID3v2.4 is prohibited (it is not fully supported; allow on your own risk).
id3v23_unsync => 0
Embedded JPEG images must not be unsynchronized.
Page created in 0.063 seconds with 21 queries.