Page 1 of 1

Thumbnail creation takes time

Posted: 2016-05-12T01:38:08-07:00
by ankush
Hello all,

I am using imagemagick to convert a 1st page of pdf to a thumbnail.

I am using command -

Code: Select all

convert file.pdf[0] -background white -flatten -resize 173 -crop 173X229+0+0 -gravity NorthWest +repage test.jpg
However when the pdf is large i,e around 9mbs the time taken on my machine is around 2mins.

So how can I decrease the time to convert - maybe use a better / optimized command?
Since I only want the first page, if the command can just iterate over the first page, convert and ends the process.

Thanks,
Ankush

Re: Thumbnail creation takes time

Posted: 2016-05-12T09:25:45-07:00
by fmw42
What version of IM and what platform? Please always provide that.

Probably won't make a difference, but proper IM syntax woulud have your -gravity before the crop.

IM uses ghostscript to read PDF files. So if there is a limitation, it is in ghostscript.

What is mbs? Do you mean mega bytes or mega bits?

Re: Thumbnail creation takes time

Posted: 2016-05-13T01:56:55-07:00
by ankush
OS - Ubuntu 14.04
IM Version - 6.7.7 and 7.0.1
the file size is over 9MB (Mega Bytes) .

I'll look into Ghostscript.
Any other solutions would be helpful.

Re: Thumbnail creation takes time

Posted: 2016-05-13T03:03:57-07:00
by ankush
Ok, so i found there a solution
If I use the following -

gs -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -o test2.jpg file.pdf

I get the result in seconds.
So I can do with on 2 things here -
a) I can change the command line params to gs
b) Find out imagemagic-convert params equivalent to -dFirstPage=1 -dLastPage=1

Re: Thumbnail creation takes time

Posted: 2016-05-13T09:20:24-07:00
by fmw42
You can change the gs params in the delegates.xml file.

Re: Thumbnail creation takes time

Posted: 2016-05-13T10:30:07-07:00
by ankush
Alright I added -dFirstPage=1 -dLastPage=1 in delegate.xml, Its still taking a lot of time when I run the same command. Irrespective of whether I give file.pdf[0] or file.pdf

Obviously, IM is evaluating the whole file again. But it should just convert 1st page. What do you think seems to be issue?

Re: Thumbnail creation takes time

Posted: 2016-05-13T10:34:54-07:00
by snibgo
"-verbose" will show the GS command used, so may provide some insight.