Re: gm convert bla.jpg bla.pdf multiplies SEVENFOLD the file's size !

Bob Friesenhahn <[email protected]> Sat, 8 Dec 2018 13:43:08 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.bugs
Message-ID <[email protected]>
On Sat, 8 Dec 2018, Mehdi wrote:

> But I don't want to compress it, I want the size to simply be the same.
> Before, with Imagesmagick, I did just "convert *.JPG livre.pdf" and it was
> done. Your program will have trouble be accepted as the successor if the
> commands and defaults are not the same...

I don't anticipate that GraphicsMagick will become the successor to 
ImageMagick, but it is a useful alternative.  I am quite sure that it 
is a useful alternative, which is more effective depending on what is 
being done.

There is only so much that can be done in uncompensated spare time. 
I have been working (without pay) on Imagemagick and then 
GraphicsMagick software for 22 years already.

Your input files (JPEG) are already compressed using JPEG compression. 
It makes sense to also use JPEG compression in PDF (which it should 
already be doing by default if the input was JPEG).  In my testing I 
see that the PDF equivalent is about 28% larger than the original JPEG 
file.

If your files were grayscale or it is ok for them to be grayscale then 
there are other compression algorithms which may be better than JPEG 
or the data can be compressed using JPEG but only as a grayscale 
image.

I should think that

   gm convert *.JPG -type Optimize output.pdf

wiill help if some images are not full color images.

> Pdf to me is just a fine way to add pictures in a column to read with my
> Kindle, nothing more. Though if you do have another format for that, I'll
> all yours !

Does your Kindle have a color screen or is it black/white?  Do you 
need to see the images in color?  Is ok for the images to be dithered?

> Also, I have 6 processors and 3 Go of memory (had less before and it used
> to work). Yet, each time more than 10 files or so are merged, *everything *is
> freezed, all ressources are stolen while I don't even know if the task is
> done faster or if it's a waste. Either way, that's a very bad default,
> stealing everything.

It is possible that your system puts its temporary files on the 
equivalent of a RAM drive so temporary files intended to save memory 
are actually using memory.  You can create a dedicated directory for 
GraphicsMagick temporary files on a hard drive and this may help:

mkdir $HOME/magicktmp
export MAGICK_TMPDIR=$HOME/magicktmp
gm convert -verbose -limit memory 1GB *.JPG -type Optimize output.pdf

> I know nothing of the config system, and it's unlikely I'll ever want or
> have to touch it again... Could you tell  how to set it (using all
> ressources available but not so as to litterally freeze the screen) ? I
> guess it relates to process priority, but I hope I don't have to touch
> "nice" too.

Freezing the screen is not nice.  This usually means that the system 
was paging to the paging ("swap") device.

Create a dedicated temporary file area and use the -limit memory 
option as suggested above.  If the memory limit is reached, then 
temporary files are used.

On a 7-year old Linux system, I see that GM was able to take many JPEG 
files (some very large and some small) and write them to a 78M PDF 
file in 8 seconds.  Peak RAM memory used was 1.5GB.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt