in reply to Re: Size problem of pdf file using ImageMagick
in thread Size problem of pdf file using ImageMagick

I have obtained these images by scanning the drawings in just two colours.
I see your comments about the alternate graphicsmagick but I would prefer to stick with imagemagick.
Using comments from both replies I altered the Perl so that the jpg and pdf were saved as before and then saved again using LZW compression and a quality of 75. This gave four files. The code follows
$mod_file_name = $file_name_jpg; $mod_dp = '-' . $jv . 'pc.'; # normal $mod_file_name =~ s/\./$mod_dp/; $rc = $img_copy->Write($dir_name . '\\' . $mod_file_name); $mod_file_name =~ s/jpg/pdf/; $rc = $img_copy->Write($dir_name . '\\' . $mod_file_name); # compressed $mod_file_name = $file_name_jpg; $mod_dp = '-' . $jv . 'pc-compressed.'; $mod_file_name =~ s/\./$mod_dp/; $rc = $img_copy->Write(filename => $dir_name . '\\' . $mod_file_name, +compression => 'LZW', quality => 75); $mod_file_name =~ s/jpg/pdf/; $rc = $img_copy->Write(filename => $dir_name . '\\' . $mod_file_name, +compression => 'LZW', quality => 75);
For one jpg file I obtained the four files for:
1. The original jpg file
2. After using Scale to reduce the size of the image by 2 (in x and y)
The file sizes were for full size
jpg 1,099 kb
pdf 1,331 kb
jpg compressed 742 kb
pdf compressed 2,144 kb
The file sizes were for half size
jpg 304 kb
pdf 660 kb
jpg compressed 304 kb
pdf compressed 660 kb
This was not what I was expecting since:
For full size – although the compressed jpg was smaller than the uncompressed version, the compressed pdf was nearly twice as large as the uncompressed version
For half size –there was no change between the compressed and uncompressed version.
Does it make sense that the compressed pdf is larger than the original and why does compression seem to have effect after scale had been used on the original image?