Codebase list libimager-perl / a9072e1
Import upstream version 1.004004+git20210425.1.20e5de0 Debian Janitor 2 years ago
11 changed file(s) with 145 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
00 Imager release history. Older releases can be found in Changes.old
1
2 - added rgb_difference() method
3 Thanks to Andreas König
4 https://github.com/tonycoz/imager/pull/462
15
26 Imager 1.012 - 14 Jun 2020
37 ============
553557 significantly reduce file sizes, but uses more memory and time.
554558 https://rt.cpan.org/Ticket/Display.html?id=94292
555559
556 - the autolevels filter now works on the luminosity of the image
560 - the autolevels filter now works on the luminance of the image
557561 rather then working per channel. The old autolevels filter is
558562 still available as "autolevels_skew".
559563 https://rt.cpan.org/Ticket/Display.html?id=94413
12161216 - string now documented in Imager::Draw
12171217 - add parameter list documentation
12181218 - document the utf8 parameter for bounding_box(), has_chars()
1219 Resolves: http://rt.cpan.org/NoAuth/Bug.html?id=13508
1219 Resolves: http://rt.cpan.org/NoAuth/Bug.html?id=13058
12201220 - decode the EXIF GPS IFD as well
12211221 - minor documentation touchups
12221222 - bump version 0.45_01
39413941 return $result;
39423942 }
39433943
3944 sub rgb_difference {
3945 my ($self, %opts) = @_;
3946
3947 $self->_valid_image("rgb_difference")
3948 or return;
3949
3950 defined $opts{other}
3951 or return $self->_set_error("No 'other' parameter supplied");
3952 unless ($opts{other}->_valid_image("rgb_difference")) {
3953 $self->_set_error($opts{other}->errstr . " (other image)");
3954 return;
3955 }
3956
3957 my $result = Imager->new;
3958 $result->{IMG} = i_rgbdiff_image($self->{IMG}, $opts{other}{IMG})
3959 or return $self->_set_error($self->_error_as_msg());
3960
3961 return $result;
3962 }
3963
39443964 # destructive border - image is shrunk by one pixel all around
39453965
39463966 sub border {
49794999
49805000 register_writer() - L<Imager::Files/register_writer()>
49815001
5002 rgb_difference() - L<Imager::Filters/rgb_difference()> - produce a difference
5003 images from two input images.
5004
49825005 rotate() - L<Imager::Transformations/rotate()>
49835006
49845007 rubthrough() - L<Imager::Transformations/rubthrough()> - draw an image
30503050 Imager::ImgRaw im2
30513051 im_double mindist
30523052
3053 Imager::ImgRaw
3054 i_rgbdiff_image(im, im2)
3055 Imager::ImgRaw im
3056 Imager::ImgRaw im2
3057
30533058 undef_int
30543059 i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs)
30553060 Imager::ImgRaw im
33 "Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson"
44 ],
55 "dynamic_config" : 0,
6 "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
6 "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010",
77 "license" : [
88 "perl_5"
99 ],
6767 }
6868 },
6969 "version" : "1.012",
70 "x_serialization_backend" : "JSON::PP version 2.97001"
70 "x_serialization_backend" : "JSON::PP version 4.04"
7171 }
88 configure_requires:
99 ExtUtils::MakeMaker: '0'
1010 dynamic_config: 0
11 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010'
11 generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010'
1212 license: perl
1313 meta-spec:
1414 url: http://module-build.sourceforge.net/META-spec-v1.4.html
14461446 ysize = i_min(im1->ysize, im2->ysize);
14471447
14481448 out = i_sametype_chans(im1, xsize, ysize, outchans);
1449
1449
14501450 if (im1->bits == i_8_bits && im2->bits == i_8_bits) {
14511451 i_color *line1 = mymalloc(xsize * sizeof(*line1)); /* checked 17feb2005 tonyc */
14521452 i_color *line2 = mymalloc(xsize * sizeof(*line1)); /* checked 17feb2005 tonyc */
15231523 return out;
15241524 }
15251525
1526 /*
1527 =item i_rgbdiff_image(im1, im2)
1528
1529 Creates a new image that is black, except where the pixel in im2 is
1530 different from im1, where it is the arithmetical difference to im2 per
1531 color.
1532
1533 =cut
1534 */
1535
1536 i_img *
1537 i_rgbdiff_image(i_img *im1, i_img *im2) {
1538 i_img *out;
1539 int outchans, diffchans;
1540 i_img_dim xsize, ysize;
1541 dIMCTXim(im1);
1542
1543 i_clear_error();
1544 if (im1->channels != im2->channels) {
1545 i_push_error(0, "different number of channels");
1546 return NULL;
1547 }
1548
1549 outchans = diffchans = im1->channels;
1550 if (outchans == 2 || outchans == 4)
1551 --outchans;
1552
1553 xsize = i_min(im1->xsize, im2->xsize);
1554 ysize = i_min(im1->ysize, im2->ysize);
1555
1556 out = i_sametype_chans(im1, xsize, ysize, outchans);
1557
1558 #code im1->bits == i_8_bits && im2->bits == i_8_bits
1559 IM_COLOR *line1 = mymalloc(xsize * sizeof(*line1));
1560 IM_COLOR *line2 = mymalloc(xsize * sizeof(*line1));
1561 i_img_dim x, y;
1562 int ch;
1563
1564 for (y = 0; y < ysize; ++y) {
1565 IM_GLIN(im1, 0, xsize, y, line1);
1566 IM_GLIN(im2, 0, xsize, y, line2);
1567 for (x = 0; x < xsize; ++x) {
1568 for (ch = 0; ch < outchans; ++ch) {
1569 line2[x].channel[ch] = IM_ABS(line1[x].channel[ch] - line2[x].channel[ch]);
1570 }
1571 }
1572 IM_PLIN(out, 0, xsize, y, line2);
1573 }
1574 myfree(line1);
1575 myfree(line2);
1576 #/code
1577
1578 return out;
1579 }
1580
15261581 struct fount_state;
15271582 static double linear_fount_f(double x, double y, struct fount_state *state);
15281583 static double bilinear_fount_f(double x, double y, struct fount_state *state);
292292 void i_gradgen(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure);
293293 int i_nearest_color(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure);
294294 i_img *i_diff_image(i_img *im, i_img *im2, double mindist);
295 i_img *i_rgbdiff_image(i_img *im, i_img *im2);
295296 int
296297 i_fountain(i_img *im, double xa, double ya, double xb, double yb,
297298 i_fountain_type type, i_fountain_repeat repeat,
153153
154154 =item C<autolevels>
155155
156 Scales the luminosity of the image so that the luminosity will cover
156 Scales the luminance of the image so that the luminance will cover
157157 the possible range for the image. C<lsat> and C<usat> truncate the
158158 range by the specified fraction at the top and bottom of the range
159159 respectively.
807807
808808 =back
809809
810 =item rgb_difference()
811
812 You can create a new image that is the difference between 2 other images.
813
814 my $diff = $img->rgb_difference(other=>$other_img);
815
816 For each pixel in $img that is different to the pixel in $other_img,
817 the arithmetic difference for the value of the pixel in $img from
818 $other_img per color is given. Transparency is ignored.
819
820 This can be used for measuring image differences ("How much are they
821 different?").
822
823 Note that $img and $other_img must have the same number of channels.
824 The width and height of $diff will be the minimum of each of the width
825 and height of $img and $other_img.
826
827 Parameters:
828
829 =over
830
831 =item *
832
833 C<other> - the other image object to compare against
834
835 =back
836
837 =back
838
810839 =head1 AUTHOR
811840
812841 Arnar M. Hrafnkelsson, Tony Cook <tonyc@cpan.org>.
77 our @EXPORT = qw(preprocess);
88 our @ISA = qw(Exporter);
99
10 our $VERSION = "1.002";
10 our $VERSION = "1.003";
1111
1212 sub preprocess {
1313 unshift @ARGV, grep /^-/, shellwords($ENV{IMAGER_PREPROCESS_OPTS})
138138 s/\bIM_LIMIT\(/IM_LIMIT_8(/g;
139139 s/\bIM_RENDER_LINE\(/i_render_line(/g;
140140 s/\bIM_FILL_COMBINE_F\b/i_fill_combine_f/g;
141 s/\bIM_ABS\b/abs/g;
141142 }
142143
143144 @lines;
167168 s/\bIM_LIMIT\(/IM_LIMIT_double(/g;
168169 s/\bIM_RENDER_LINE\(/i_render_linef(/g;
169170 s/\bIM_FILL_COMBINE_F\b/i_fill_combinef_f/g;
171 s/\bIM_ABS\b/fabs/g;
170172 }
171173
172174 @lines;
280282
281283 =item *
282284
285 IM_ABS(sample) - calculate the absolute value of an IM_WORK_T value.
286
287 =item *
288
283289 IM_SAMPLE_MAX - maximum value for a sample
284290
285291 =item *
00 #!perl -w
11 use strict;
22 use Imager qw(:handy);
3 use Test::More tests => 136;
3 use Test::More tests => 137;
44
55 -d "testout" or mkdir "testout";
66
429429 my $cmp2 = Imager->new(xsize => 3, ysize => 2, channels => 4);
430430 $cmp2->setpixel(x => 2, 'y' => 0, color => '#FF02FF');
431431 is_image($diff2, $cmp2, "difference() - check image with mindist 1");
432
433 $im1 = Imager->new(xsize => 3, ysize => 2, channels => 4);
434 $im2 = $im1->copy;
435 $im1->setpixel(x => 1, 'y' => 0, color => 'FF00FF80');
436 $im2->setpixel(x => 1, 'y' => 0, color => 'FF01FF84');
437 $im1->setpixel(x => 2, 'y' => 0, color => 'FF00FF80');
438 $im2->setpixel(x => 2, 'y' => 0, color => 'FF02FF84');
439 my $diff3 = $im1->rgb_difference(other => $im2);
440 my $cmp3 = Imager->new(xsize => 3, ysize => 2, channels => 3);
441 $cmp3->box(filled => 1, color => '#000000');
442 $cmp3->setpixel(x => 1, 'y' => 0, color => '#000100');
443 $cmp3->setpixel(x => 2, 'y' => 0, color => '#000200');
444 is_image($diff3, $cmp3, "rgb_difference() - check image");
432445 }
433446
434447 {