faster jpeg resizing with imagemagick
by Gerald Oskoboiny <gerald@impressive.net>
|
| Date: |
Fri, 13 Jun 2003 18:26:34 -0400 |
| To: |
fogo@impressive.net |
| Replies: |
reagle |
|
I found a page with misc imagemagick tips [1], and this one on
faster jpeg resizing looks really useful:
> The -size option tells the IM jpeg decoder that the image being read
> will be resized later. This lets it run faster by avoiding returning
> full-resolution images, for later resizing.
gerald@devo:/tmp; time convert -resize 256x192 a.jpg a-sm.jpg
real 0m16.737s
user 0m10.460s
sys 0m0.250s
gerald@devo:/tmp; time convert -size 512x384 -resize 256x192 a.jpg a-sm.jpg
real 0m2.487s
user 0m1.490s
sys 0m0.060s
(a.jpg is a 2048x1536 photo, 1745586 bytes. The times above are
extra slow because both CPUs are also busy doing wavs->oggs :)
Does anyone know if doing this is a bad idea for some reason?
I'd like to use this when generating thumbnails and other smaller
versions of photos; I don't see any difference at e.g. 400x300.
That part of my photo publishing process is really time consuming
(well, just for the machine, but I have to wait around for it);
would be nice to speed it up by a factor of 5+ :)
I wonder what the difference is between -resize and -geometry; I
have always used -geometry.
the whole tip:
> Faster JPEG resizing
>
> The -size option tells the IM jpeg decoder that the image being read
> will be resized later. This lets it run faster by avoiding returning
> full-resolution images, for later resizing.
>
> For example...
> convert -size 120x120 cockatoo.jpg -resize 120x120 \
> +profile "*" cockatoo_thumb.gif
>
> This may not give as nice as a result as just the -resize filter itself, but
> it is a lot faster. If you like you could also use -size to scale part way and
> -resize to finalize. For example if you are starting with a 3000x2000 jpeg
> and want a 120x80 thumbnail, you could use "-size 480x320" then "-resize
> 120x80"
>
> NOTE: -resize uses the filter selected with -filter while -scale uses a
> simple fast scaling method. -resize & -filter give you more control
> but might consume more CPU time.
[1] http://www.sct.gu.edu.au/~anthony/info/graphics/imagemagick.hints
--
Gerald Oskoboiny <gerald@impressive.net>
http://impressive.net/people/gerald/
HURL: fogo mailing list archives,
maintained by Gerald Oskoboiny