Thumbnail creation takes time

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
ankush
Posts: 4
Joined: 2016-05-12T01:30:28-07:00
Authentication code: 1151

Thumbnail creation takes time

Post by ankush » 2016-05-12T01:38:08-07:00

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

User avatar
fmw42
Posts: 25536
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnail creation takes time

Post by fmw42 » 2016-05-12T09:25:45-07:00

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?

ankush
Posts: 4
Joined: 2016-05-12T01:30:28-07:00
Authentication code: 1151

Re: Thumbnail creation takes time

Post by ankush » 2016-05-13T01:56:55-07:00

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.

ankush
Posts: 4
Joined: 2016-05-12T01:30:28-07:00
Authentication code: 1151

Re: Thumbnail creation takes time

Post by ankush » 2016-05-13T03:03:57-07:00

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

User avatar
fmw42
Posts: 25536
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnail creation takes time

Post by fmw42 » 2016-05-13T09:20:24-07:00

You can change the gs params in the delegates.xml file.

ankush
Posts: 4
Joined: 2016-05-12T01:30:28-07:00
Authentication code: 1151

Re: Thumbnail creation takes time

Post by ankush » 2016-05-13T10:30:07-07:00

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?

snibgo
Posts: 12138
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Thumbnail creation takes time

Post by snibgo » 2016-05-13T10:34:54-07:00

"-verbose" will show the GS command used, so may provide some insight.
snibgo's IM pages: im.snibgo.com

Post Reply