Question

I use ImageMagick to generate previews. On big images(>3mb) it works really slow(for about 1-3 sec for call). Can I generate several previews at one call? I think this would be quicker.

I do this:

convert file.jpg -thumbnail 800x480 preview_800x480.jpg
convert file.jpg -thumbnail 700x400 preview_700x400.jpg
convert file.jpg -thumbnail 72x72 preview_800x480.jpg

...

And I want to do something like this:

convert file.jpg -thumbnail 800x480 preview_800x480.jpg 700x400 preview_700x400.jpg

But such command generates only last file preview_700x400.jpg. How it should be written to work properly?

Was it helpful?

Solution

This is using php but you do not say how you are running the code and you should be able to convert it to the method you are using.

$cmd = " file.jpg \( -clone 0 -thumbnail 800x480 -write preview_800x480.jpg +delete \)". 
" \( -clone 0 -thumbnail 700x400 -write preview_700x400.jpg +delete \) ". 
" -thumbnail 72x72 null: ";
exec("convert $cmd preview_800x480.jpg ");

Sometimes the null: causes a problem; if so try without.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top