Import upstream version 1.004004+git20210425.1.20e5de0
Debian Janitor
2 years ago
0 | 0 | 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 | |
1 | 5 | |
2 | 6 | Imager 1.012 - 14 Jun 2020 |
3 | 7 | ============ |
553 | 557 | significantly reduce file sizes, but uses more memory and time. |
554 | 558 | https://rt.cpan.org/Ticket/Display.html?id=94292 |
555 | 559 | |
556 | - the autolevels filter now works on the luminosity of the image | |
560 | - the autolevels filter now works on the luminance of the image | |
557 | 561 | rather then working per channel. The old autolevels filter is |
558 | 562 | still available as "autolevels_skew". |
559 | 563 | https://rt.cpan.org/Ticket/Display.html?id=94413 |
1216 | 1216 | - string now documented in Imager::Draw |
1217 | 1217 | - add parameter list documentation |
1218 | 1218 | - 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 | |
1220 | 1220 | - decode the EXIF GPS IFD as well |
1221 | 1221 | - minor documentation touchups |
1222 | 1222 | - bump version 0.45_01 |
3941 | 3941 | return $result; |
3942 | 3942 | } |
3943 | 3943 | |
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 | ||
3944 | 3964 | # destructive border - image is shrunk by one pixel all around |
3945 | 3965 | |
3946 | 3966 | sub border { |
4979 | 4999 | |
4980 | 5000 | register_writer() - L<Imager::Files/register_writer()> |
4981 | 5001 | |
5002 | rgb_difference() - L<Imager::Filters/rgb_difference()> - produce a difference | |
5003 | images from two input images. | |
5004 | ||
4982 | 5005 | rotate() - L<Imager::Transformations/rotate()> |
4983 | 5006 | |
4984 | 5007 | rubthrough() - L<Imager::Transformations/rubthrough()> - draw an image |
3050 | 3050 | Imager::ImgRaw im2 |
3051 | 3051 | im_double mindist |
3052 | 3052 | |
3053 | Imager::ImgRaw | |
3054 | i_rgbdiff_image(im, im2) | |
3055 | Imager::ImgRaw im | |
3056 | Imager::ImgRaw im2 | |
3057 | ||
3053 | 3058 | undef_int |
3054 | 3059 | i_fountain(im, xa, ya, xb, yb, type, repeat, combine, super_sample, ssample_param, segs) |
3055 | 3060 | Imager::ImgRaw im |
3 | 3 | "Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson" |
4 | 4 | ], |
5 | 5 | "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", | |
7 | 7 | "license" : [ |
8 | 8 | "perl_5" |
9 | 9 | ], |
67 | 67 | } |
68 | 68 | }, |
69 | 69 | "version" : "1.012", |
70 | "x_serialization_backend" : "JSON::PP version 2.97001" | |
70 | "x_serialization_backend" : "JSON::PP version 4.04" | |
71 | 71 | } |
8 | 8 | configure_requires: |
9 | 9 | ExtUtils::MakeMaker: '0' |
10 | 10 | 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' | |
12 | 12 | license: perl |
13 | 13 | meta-spec: |
14 | 14 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
1446 | 1446 | ysize = i_min(im1->ysize, im2->ysize); |
1447 | 1447 | |
1448 | 1448 | out = i_sametype_chans(im1, xsize, ysize, outchans); |
1449 | ||
1449 | ||
1450 | 1450 | if (im1->bits == i_8_bits && im2->bits == i_8_bits) { |
1451 | 1451 | i_color *line1 = mymalloc(xsize * sizeof(*line1)); /* checked 17feb2005 tonyc */ |
1452 | 1452 | i_color *line2 = mymalloc(xsize * sizeof(*line1)); /* checked 17feb2005 tonyc */ |
1523 | 1523 | return out; |
1524 | 1524 | } |
1525 | 1525 | |
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 | ||
1526 | 1581 | struct fount_state; |
1527 | 1582 | static double linear_fount_f(double x, double y, struct fount_state *state); |
1528 | 1583 | static double bilinear_fount_f(double x, double y, struct fount_state *state); |
292 | 292 | void i_gradgen(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure); |
293 | 293 | int i_nearest_color(i_img *im, int num, i_img_dim *xo, i_img_dim *yo, i_color *ival, int dmeasure); |
294 | 294 | 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); | |
295 | 296 | int |
296 | 297 | i_fountain(i_img *im, double xa, double ya, double xb, double yb, |
297 | 298 | i_fountain_type type, i_fountain_repeat repeat, |
153 | 153 | |
154 | 154 | =item C<autolevels> |
155 | 155 | |
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 | |
157 | 157 | the possible range for the image. C<lsat> and C<usat> truncate the |
158 | 158 | range by the specified fraction at the top and bottom of the range |
159 | 159 | respectively. |
807 | 807 | |
808 | 808 | =back |
809 | 809 | |
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 | ||
810 | 839 | =head1 AUTHOR |
811 | 840 | |
812 | 841 | Arnar M. Hrafnkelsson, Tony Cook <tonyc@cpan.org>. |
7 | 7 | our @EXPORT = qw(preprocess); |
8 | 8 | our @ISA = qw(Exporter); |
9 | 9 | |
10 | our $VERSION = "1.002"; | |
10 | our $VERSION = "1.003"; | |
11 | 11 | |
12 | 12 | sub preprocess { |
13 | 13 | unshift @ARGV, grep /^-/, shellwords($ENV{IMAGER_PREPROCESS_OPTS}) |
138 | 138 | s/\bIM_LIMIT\(/IM_LIMIT_8(/g; |
139 | 139 | s/\bIM_RENDER_LINE\(/i_render_line(/g; |
140 | 140 | s/\bIM_FILL_COMBINE_F\b/i_fill_combine_f/g; |
141 | s/\bIM_ABS\b/abs/g; | |
141 | 142 | } |
142 | 143 | |
143 | 144 | @lines; |
167 | 168 | s/\bIM_LIMIT\(/IM_LIMIT_double(/g; |
168 | 169 | s/\bIM_RENDER_LINE\(/i_render_linef(/g; |
169 | 170 | s/\bIM_FILL_COMBINE_F\b/i_fill_combinef_f/g; |
171 | s/\bIM_ABS\b/fabs/g; | |
170 | 172 | } |
171 | 173 | |
172 | 174 | @lines; |
280 | 282 | |
281 | 283 | =item * |
282 | 284 | |
285 | IM_ABS(sample) - calculate the absolute value of an IM_WORK_T value. | |
286 | ||
287 | =item * | |
288 | ||
283 | 289 | IM_SAMPLE_MAX - maximum value for a sample |
284 | 290 | |
285 | 291 | =item * |
0 | 0 | #!perl -w |
1 | 1 | use strict; |
2 | 2 | use Imager qw(:handy); |
3 | use Test::More tests => 136; | |
3 | use Test::More tests => 137; | |
4 | 4 | |
5 | 5 | -d "testout" or mkdir "testout"; |
6 | 6 | |
429 | 429 | my $cmp2 = Imager->new(xsize => 3, ysize => 2, channels => 4); |
430 | 430 | $cmp2->setpixel(x => 2, 'y' => 0, color => '#FF02FF'); |
431 | 431 | 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"); | |
432 | 445 | } |
433 | 446 | |
434 | 447 | { |