Re: converting 360 pages' pdf file take too much memory

Bob Friesenhahn <[email protected]> Fri, 10 Mar 2017 08:32:31 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---559023410-476409993-1489156351=:13280
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by smtp.simplesystems.org
	id v2AEWVQI003936

On Fri, 10 Mar 2017, =E7=8E=8B=E5=8F=AF wrote:

> If I increase image density with overwrited readImages, the memory usag=
e is
> higher.
> Since api read and output each page one by one, why it take so much mem=
ory
> and is there any solution for it?
>
> Another question is, When I run the program, A progress "gs"  runs in
> background and exits after a while, then I can see process of my progra=
m in
> process list.
> I do not understand what 'gs' process is and how it running.

GraphicsMagick always reads all input pages/frames before it proceeds=20
to do anything more.

GraphicsMagick uses Ghostscript ('gs') to render the PDF (or=20
Postscript) into a sequence of raster image files which are then read=20
into GraphicsMagick's internal format.  Someday this may be improved=20
but the Ghostscript license is not conducive to direct linkage between=20
GM and Ghostscript.  Perhaps a different PDF renderer would be used.

There is a way to read just a range of pages by appending a page range=20
to the input file name.  For example

   readImages(&images, "/test/linuxfun.pdf[0-49]");

should read the first 50 pages.  When dealing with large PDFs, you can=20
incrementally read batches of pages from the same file in order to=20
limit resource consumption.  You will know when you reach the end of=20
the PDF due to obtaining fewer pages than requested.

This works better for PDF than for Postscript because PDF is indexed=20
and Postscript is not.

Even with incremental reading, there will still be a resource issue=20
unless your program is able to deal with a subset of pages at a time.

Bob

--=20
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen=
/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
---559023410-476409993-1489156351=:13280
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
---559023410-476409993-1489156351=:13280
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis

---559023410-476409993-1489156351=:13280--