int comment_entry;
int want_channels = im->channels;
int progressive = 0;
+ int optimize = 0;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
if (progressive) {
jpeg_simple_progression(&cinfo);
}
+ if (!i_tags_get_int(&im->tags, "jpeg_optimize", 0, &optimize))
+ optimize = 0;
+ cinfo.optimize_coding = optimize;
got_xres = i_tags_get_float(&im->tags, "i_xres", 0, &xres);
got_yres = i_tags_get_float(&im->tags, "i_yres", 0, &yres);
$Imager::formats{"jpeg"}
or plan skip_all => "no jpeg support";
-plan tests => 103;
+plan tests => 109;
print STDERR "libjpeg version: ", Imager::File::JPEG::i_libjpeg_version(), "\n";
is_image($rdprog, $norm, "prog vs norm should be the same image");
}
+SKIP:
+{ # optimize coding
+ my $im = test_image();
+ my $base;
+ ok($im->write(data => \$base, type => "jpeg"), "save without optimize");
+ my $opt;
+ ok($im->write(data => \$opt, type => "jpeg", jpeg_optimize => 1),
+ "save with optimize");
+ cmp_ok(length $opt, '<', length $base, "check optimized is smaller");
+ my $im_base = Imager->new(data => $base, filetype => "jpeg");
+ ok($im_base, "read unoptimized back");
+ my $im_opt = Imager->new(data => $opt, filetype => "jpeg");
+ ok($im_opt, "read optimized back");
+ $im_base && $im_opt
+ or skip "couldn't read one back", 1;
+ is_image($im_opt, $im_base,
+ "optimization should only change huffman compression, not quality");
+}
+
{ # check close failures are handled correctly
my $im = test_image();
my $fail_close = sub {
JPEG supports the spatial resolution tags C<i_xres>, C<i_yres> and
C<i_aspect_only>.
+You can also set the following tags when writing to an image, they are
+not set in the image when reading:
+
+=over
+
+C<jpeg_optimize> - set to a non-zero integer to compute optimal
+Huffman coding tables for the image. This will increase memory usage
+and processing time (about 12% in my simple tests) but can
+significantly reduce file size without a loss of quality.
+
+=back
+
=for stopwords EXIF
If an C<APP1> block containing EXIF information is found, then any of the