Page 1 of 1
why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T10:46:18-07:00
by skiiiks
$ time /usr/bin/convert -size "720x>" photo1.jpg -thumbnail "720x>" photo2.jpg
real 0m1.248s
user 0m0.472s
sys 0m0.048s
$ time /usr/bin/convert -size "x720>" photo1.jpg -thumbnail "x720>" photo2.jpg
real 0m2.555s
user 0m0.932s
sys 0m0.160s
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T10:55:22-07:00
by NicolasRobidoux
Because, to resize horizontally, you only need one scanline (pixel row) to compute a given pixel (if some common technical conditions are satisfied and taken advantage of), and to resize vertically, you need several. In IM, resizing is, by default, scanline based. Consequently, memory is accessed more efficiently when resizing horizontally.
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T11:01:53-07:00
by skiiiks
is there a faster way to do a simple resize ?
i need the image to be as much 720 in X or Y keeping aspect ratio ... that's because I use one or other command depending width > height or viceversa
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T11:05:08-07:00
by fmw42
-scale and -sample are generally faster than -resize, but they do not do antialiasing with any filters. If downsampling, then -scale with average blocks of pixels and -sample will use nearest neighbor subsampling. Thus the quality won't be as good.
Only other way to speed things up is with multiprocessors and OpenMP enabled in IM, as far as I know.
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T11:11:17-07:00
by NicolasRobidoux
Do I understand correctly that you are resizing in only one direction?
In that case, you may get a speed gain without much quality loss by changing away from the standard filter (which may be Mitchell or Lanczos depending on the type of input image). I suggest
Even if you are resizing in both directions (at least some of the time), you should check whether the results obtained with filters with small support are satisfactory.
In increasing order of complexity, the "cheapest" ones are Triangle, Hermite and Quadratic. (It turns out that all three work well with transparency, and are "halo free." Triangle shows a lot of "ridging," Hermite shows a lot of "jaggies," and Quadratic is quite blurry.
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T11:21:03-07:00
by NicolasRobidoux
You may also speed up IM by compiling with the Quantum equal to exactly the desired bit-depth of your input and output images.
Re: why is faster to resize horizontally than vertically ?
Posted: 2011-02-25T17:09:06-07:00
by anthony
You could also type using -distort resizing BUT setting -filter point -interpolate bilinear
That turns of the distorts use of a filter (EWA) and instead uses interpolated pixel lookup
I can not guarantee it will be faster, but it might be.