$ 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
why is faster to resize horizontally than vertically ?
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: why is faster to resize horizontally than vertically ?
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.
Last edited by NicolasRobidoux on 2011-02-26T14:57:19-07:00, edited 1 time in total.
Re: why is faster to resize horizontally than vertically ?
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: why is faster to resize horizontally than vertically ?
-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.
Only other way to speed things up is with multiprocessors and OpenMP enabled in IM, as far as I know.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: why is faster to resize horizontally than vertically ?
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.
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
Code: Select all
-filter Hermite
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.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: why is faster to resize horizontally than vertically ?
You may also speed up IM by compiling with the Quantum equal to exactly the desired bit-depth of your input and output images.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: why is faster to resize horizontally than vertically ?
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/