batch image resize

Alexander Skwar listen at alexander.skwar.name
Sat Jul 29 15:32:43 UTC 2006


· albi <albi at scii.nl>:

> On Sat, 29 Jul 2006 16:07:37 +0200
> Alexander Skwar <listen at alexander.skwar.name> wrote:
> 
>> > use instead e.g. convert *.jpg -resize 640×480
>> 
>> This won't work. Use mogrify instead (also in the imagemagick
>> package).

Sorry. I should have said: "This won't work as expected to.".

> ok, that example was wrong, but i've been using this myself
> recently :
> convert -size 640x480 *jpg

This example is still bad. AGAIN: Use mogrify, if you want to use
something like "*jpg" in the command line call. And "resize" is
fine to use.

Proof for what I wrote:

alexander at knospe:/dev/shm/img$ ls -la
insgesamt 492
drwxr-xr-x 2 alexander alexander     80 2006-07-29 17:23 .
drwxrwxrwt 4 root      root          80 2006-07-29 17:23 ..
-rw-r--r-- 1 alexander alexander  19531 2006-07-29 17:23 dogwaffle.jpg
-rw-r--r-- 1 alexander alexander 473084 2006-07-29 17:23 examples.jpg
alexander at knospe:/dev/shm/img$ ocnve
alexander at knospe:/dev/shm/img$ convert -verbose -size 640x480 *jpg
dogwaffle.jpg JPEG 467x59 DirectClass 19kb
dogwaffle.jpg JPEG 467x59 DirectClass 19kb
dogwaffle.jpg=>examples.jpg JPEG 467x59 DirectClass 19kb

Now, if you actually expected that the converted dogwaffle.jpg
should overwrite examples.jpg, then all is well of course. But
that's most often not expected, I'd suppose.

> -> and it does auto-rename the new 
> pictures

Proven to be wrong. At least in the general case. And otherwise, the
result might not be, as one expects it to.

alexander at knospe:/dev/shm/img$ ls -la
insgesamt 152
drwxr-xr-x 2 alexander alexander   100 2006-07-29 17:28 .
drwxrwxrwt 4 root      root         80 2006-07-29 17:23 ..
-rw-r--r-- 1 alexander alexander 19531 2006-07-29 17:23 dogwaffle.jpg
-rw-r--r-- 1 alexander alexander 88631 2006-07-29 17:28 eros.jpg
-rw-r--r-- 1 alexander alexander 35083 2006-07-29 17:27 examples.jpg
alexander at knospe:/dev/shm/img$ convert -verbose -resize 800x600 *jpg
dogwaffle.jpg JPEG 467x59 DirectClass 19kb
eros.jpg JPEG 1024x512 DirectClass 87kb 0.050u 0:02
dogwaffle.jpg JPEG 467x59=>800x101 DirectClass 19kb
eros.jpg[1] JPEG 1024x512=>800x400 DirectClass 87kb
dogwaffle.jpg=>examples-0.jpg[0] JPEG 467x59=>800x101 DirectClass 34kb
eros.jpg=>examples-1.jpg[1] JPEG 1024x512=>800x400 DirectClass 52kb
alexander at knospe:/dev/shm/img$ ls -la
insgesamt 240
drwxr-xr-x 2 alexander alexander   140 2006-07-29 17:28 .
drwxrwxrwt 4 root      root         80 2006-07-29 17:23 ..
-rw-r--r-- 1 alexander alexander 19531 2006-07-29 17:23 dogwaffle.jpg
-rw-r--r-- 1 alexander alexander 88631 2006-07-29 17:28 eros.jpg
-rw-r--r-- 1 alexander alexander 35083 2006-07-29 17:28 examples-0.jpg
-rw-r--r-- 1 alexander alexander 52756 2006-07-29 17:28 examples-1.jpg
-rw-r--r-- 1 alexander alexander 35083 2006-07-29 17:27 examples.jpg

It'll get even worse, when it's used to convert to a format which
supports multiple pictures in one file (e.g. gif, tiff).

alexander at knospe:/dev/shm/img/gifs$ convert -verbose *gif
dogwaffle.gif GIF 467x59 467x59+0+0 PseudoClass 256c 23kb
eros.gif GIF 1024x512 1024x512+0+0 PseudoClass 64c 204kb
examples-0.gif GIF 800x101 800x101+0+0 PseudoClass 256c 63kb
examples-1.gif GIF 800x400 800x400+0+0 PseudoClass 64c 131kb
dogwaffle.gif GIF 467x59 467x59+0+0 PseudoClass 256c 23kb
eros.gif[1] GIF 1024x512 1024x512+0+0 PseudoClass 64c 204kb
examples-0.gif[2] GIF 800x101 800x101+0+0 PseudoClass 256c 63kb
examples-1.gif[3] GIF 800x400 800x400+0+0 PseudoClass 64c 131kb
dogwaffle.gif=>examples.gif[0] GIF 467x59 467x59+0+0 PseudoClass 256c 421kb
alexander at knospe:/dev/shm/img/gifs$ ls -la
insgesamt 872
drwxr-xr-x 2 alexander alexander    140 2006-07-29 17:31 .
drwxr-xr-x 3 alexander alexander    160 2006-07-29 17:31 ..
-rw-r--r-- 1 alexander alexander  24004 2006-07-29 17:31 dogwaffle.gif
-rw-r--r-- 1 alexander alexander 208847 2006-07-29 17:31 eros.gif
-rw-r--r-- 1 alexander alexander  64552 2006-07-29 17:31 examples-0.gif
-rw-r--r-- 1 alexander alexander 133825 2006-07-29 17:31 examples-1.gif
-rw-r--r-- 1 alexander alexander 431186 2006-07-29 17:31 examples.gif
alexander at knospe:/dev/shm/img/gifs$ identify examples.gif
examples.gif[0] GIF 467x59 467x59+0+0 PseudoClass 256c 421kb
examples.gif[1] GIF 1024x512 467x59+0+0 PseudoClass 64c 421kb
examples.gif[2] GIF 800x101 467x59+0+0 PseudoClass 256c 421kb
examples.gif[3] GIF 800x400 467x59+0+0 PseudoClass 64c 421kb

Let me say it again: Use mogrify!

Alexander Skwar
-- 
Wenn man beim Erzählen eines fremden Scherzes selbst sehr lacht, so
gewinnt er; bei dem eines eignen, so verliert er.
                -- Jean Paul






More information about the ubuntu-users mailing list